コード例 #1
0
  public Recordset HitTest(DatasetVector datasetVector, float x, float y) {
    final float tolerance = dip2px(10.0f);

    // 地理范围和手机屏幕的坐标是相反的
    Point lb = new Point((int) (x - tolerance), (int) (y + tolerance));
    Point rt = new Point((int) (x + tolerance), (int) (y - tolerance));
    Point2D leftBottom = mMapControl.getMap().pixelToMap(lb);
    Point2D rightTop = mMapControl.getMap().pixelToMap(rt);

    // 投影转换
    leftBottom =
        mapShow.convertMapToDatasetPoint(leftBottom, datasetVector.getPrjCoordSys().getType());
    rightTop = mapShow.convertMapToDatasetPoint(rightTop, datasetVector.getPrjCoordSys().getType());

    // 构造屏幕当前点10像素范围的查询Bounds
    Rectangle2D queryBounds = new Rectangle2D(leftBottom, rightTop);

    QueryParameter param = new QueryParameter();
    param.setAttributeFilter("");
    param.setSpatialQueryObject(queryBounds);
    param.setSpatialQueryMode(SpatialQueryMode.INTERSECT);
    param.setCursorType(CursorType.DYNAMIC);
    // 空间和属性联合查询
    Recordset recordset = datasetVector.query(param);

    return recordset;
  }
コード例 #2
0
  @Override
  public void DeleteOrderReceived(String msg) {
    // {delete:fieldName=PlotID,fieldValue=xxxxxxx}
    int pos = msg.indexOf(":");
    if (pos > msg.length() || pos < 0) return;
    String order = msg.substring(1, pos);
    msg = msg.substring(pos + 1);

    if (!order.equalsIgnoreCase("delete")) {
      return;
    }
    pos = msg.indexOf(",");
    if (pos > msg.length() || pos < 0) return;

    // fileName为fieldName=PlotID
    String fieldName = msg.substring(0, pos);
    msg = msg.substring(pos + 1);

    pos = fieldName.indexOf("=");
    if (pos > fieldName.length() || pos < 0) return;
    fieldName = fieldName.substring(pos + 1);
    if (!fieldName.equalsIgnoreCase("PlotID")) {
      return;
    }

    // fileValue为fieldValue=xxxxxxx}
    String fieldValue = msg.substring(0, msg.length() - 1);

    pos = fieldValue.indexOf("=");
    if (pos > fieldValue.length() || pos < 0) return;
    fieldValue = fieldValue.substring(pos + 1, msg.length() - 1);

    // 查处所有数据集对象,依次遍历找到PlotID值为fieldValue的对象,并删除????
    DatasetVector dv =
        (DatasetVector)
            (mapShow
                .getMap()
                .getWorkspace()
                .getDatasources()
                .get("multimedia")
                .getDatasets()
                .get("CAD"));
    Recordset recordset = dv.getRecordset(false, CursorType.DYNAMIC);
    recordset.moveFirst();
    while (!recordset.isEOF()) {
      String value = (String) recordset.getFieldValue(fieldName);
      if (value.equalsIgnoreCase(fieldValue)) {
        recordset.delete();
        recordset.update();
        break;
      }
      recordset.moveNext();
    }
    recordset.close();
    recordset.dispose();
  }
コード例 #3
0
  @Override
  public void onClick(View v) {
    switch (v.getId()) {
      case R.id.consult_message:
        {
          mMapControl.submit();
          mMapControl.setAction(Action.SELECT);
          mMapControl.getMap().refresh();

          if (m_popupMultiMedia != null && m_popupMultiMedia.isShowing()) {
            m_popupMultiMedia.dismiss();
          }
          if (m_PlotTypePopup != null && m_PlotTypePopup.isShowing()) {
            m_PlotTypePopup.dismiss();
          }
          m_nMessageCount = 0;
          btnNewMessage.setVisibility(4);
          showMessageList(v);
        }
        break;
      case R.id.message_switch:
        {
          if (m_popupMultiMedia != null && m_popupMultiMedia.isShowing()) {
            m_popupMultiMedia.dismiss();
          }
          if (m_PlotTypePopup != null && m_PlotTypePopup.isShowing()) {
            m_PlotTypePopup.dismiss();
          }
          mMessageQueueOn = !mMessageQueueOn;
          if (!mMessageQueueOn) {
            btnMessageSwitch.setBackgroundResource(R.drawable.btn_message_switch_noselect);
            m_MessageQueue.suspend();
          } else {
            btnMessageSwitch.setBackgroundResource(R.drawable.btn_message_switch_focused);
            m_MessageQueue.resume();

            // 先去下载一次多媒体数据
            if (m_popupMultiMedia == null) {
              // 多媒体列表初始化
              m_popupMultiMedia =
                  new MultiMediaPopup(btnMultiMedia.getRootView(), getApplicationContext(), this);
              // 设置多媒体工作空间
              m_popupMultiMedia.setWorkspace(mapShow.getWorkspace(), mapShow.getBounds());
            }
          }
        }
        break;
      case R.id.locate:
        {
          if (m_popupMultiMedia != null && m_popupMultiMedia.isShowing()) {
            m_popupMultiMedia.dismiss();
          }
          if (m_PlotTypePopup != null && m_PlotTypePopup.isShowing()) {
            m_PlotTypePopup.dismiss();
          }
          m_StartPoint = m_TencentLocation.getGPSPoint();
          if ((m_StartPoint.getX() == 0) || (m_StartPoint.getY() == 0)) {
            MyApplication.getInstance().showInfo("现在无法定位,请稍后再试!");
            break;
          }
          // 导航纠偏
          m_StartPoint = m_Navigation.encryptGPS(m_StartPoint.getX(), m_StartPoint.getY());

          Point2D pt = mapShow.getPoint(m_StartPoint);
          if (pt == null) {
            MyApplication.getInstance().showInfo("现在无法定位,请稍后再试!");
            break;
          }
          drawCircleOnDyn(pt, 0, m_TencentLocation.getAccuracy());
          mapShow.panTo(pt);
          m_MapView.refresh();
        }
        break;
      case R.id.multi_media:
        {
          mMapControl.submit();
          mMapControl.setAction(Action.SELECT);
          mMapControl.getMap().refresh();

          if (m_PlotTypePopup != null && m_PlotTypePopup.isShowing()) {
            m_PlotTypePopup.dismiss();
          }
          showMultiMediaPopup(v);
          break;
        }
      case R.id.plot:
        {
          if (m_popupMultiMedia != null && m_popupMultiMedia.isShowing()) {
            m_popupMultiMedia.dismiss();
          }

          mMapControl.submit();
          mMapControl.setAction(Action.SELECT);
          mMapControl.getMap().refresh();

          if (m_PlotTypePopup == null) {
            m_PlotTypePopup = new PlotTypePopup(mMapControl, btnPlot.getRootView(), this);
          }
          if (m_PlotTypePopup.isShowing()) {
            m_PlotTypePopup.dismiss();
            mMapControl.setAction(Action.SELECT);
          } else {
            m_PlotTypePopup.show(v);
          }

          break;
        }
      case R.id.text_message:
        {
          mMapControl.submit();
          mMapControl.setAction(Action.SELECT);
          mMapControl.getMap().refresh();

          if (m_popupMultiMedia != null && m_popupMultiMedia.isShowing()) {
            m_popupMultiMedia.dismiss();
          }
          if (m_PlotTypePopup != null && m_PlotTypePopup.isShowing()) {
            m_PlotTypePopup.dismiss();
          }
          if (!mMessageQueueOn) {
            MyApplication.getInstance().showInfo("请先打开消息开关!");
            break;
          }
          if (m_popupTextMessage == null) {
            m_popupTextMessage =
                new TextMessagePopup(btnTextMessage.getRootView(), getApplicationContext(), this);
          }

          if (m_popupTextMessage.isShowing()) {
            m_popupTextMessage.dismiss();
          } else {
            m_popupTextMessage.setFocusable(true);
            m_popupTextMessage.show();
          }
        }
        break;
      case R.id.send_message:
        {
          mMapControl.submit();
          mMapControl.setAction(Action.SELECT);
          mMapControl.getMap().refresh();

          if (m_popupMultiMedia != null && m_popupMultiMedia.isShowing()) {
            m_popupMultiMedia.dismiss();
          }
          if (m_PlotTypePopup != null && m_PlotTypePopup.isShowing()) {
            m_PlotTypePopup.dismiss();
          }
          if (!mMessageQueueOn) {
            MyApplication.getInstance().showInfo("请先打开消息开关!");
            break;
          }
          sendPlot();
        }
        break;
      case R.id.position_upload:
        {
          if (m_popupMultiMedia != null && m_popupMultiMedia.isShowing()) {
            m_popupMultiMedia.dismiss();
          }
          if (m_PlotTypePopup != null && m_PlotTypePopup.isShowing()) {
            m_PlotTypePopup.dismiss();
          }
          if (!mMessageQueueOn) {
            MyApplication.getInstance().showInfo("请先打开消息开关!");
            break;
          }
          m_StartPoint = m_TencentLocation.getGPSPoint();
          if ((m_StartPoint.getX() == 0) || (m_StartPoint.getY() == 0)) {
            MyApplication.getInstance().showInfo("现在无法定位,请稍后再试!");
            break;
          }
          // 导航纠偏
          m_StartPoint = m_Navigation.encryptGPS(m_StartPoint.getX(), m_StartPoint.getY());
          String json = m_StartPoint.toJson();
          String msg = "{content_type=0}" + json;
          boolean bOk = m_MessageQueue.sendMessageByType(msg, 0);
          if (bOk) {
            MyApplication.getInstance().showInfo("发送成功");
          } else {
            MyApplication.getInstance().showInfo("发送失败,请重新发送!");
          }
        }
        break;
      case R.id.delete:
        {
          if (m_layerSelected == null || m_IDSelected == -1) {
            break;
          }
          DatasetVector dataset = (DatasetVector) m_layerSelected.getDataset();
          if (dataset != null && dataset.getName().equalsIgnoreCase("CAD")) {
            QueryParameter parameter = new QueryParameter();
            parameter.setAttributeFilter("SmID=" + m_IDSelected);
            parameter.setCursorType(CursorType.DYNAMIC);
            Recordset recordset = dataset.query(parameter);
            recordset.moveFirst();
            if (!recordset.isEmpty()) {
              String strPlotID = (String) recordset.getFieldValue("PlotID");
              recordset.delete();
              recordset.update();
              String msg = "{content_type=5}";
              msg += "{delete:feildName=PlotID,feildValue=";
              msg += strPlotID;
              msg += "}";
              m_MessageQueue.sendMessageByRoutingKey(msg, "plot");
            }
            recordset.close();
            recordset.dispose();
          }
          mMapControl.getMap().refresh();
          mMapControl.setAction(Action.SELECT);
          m_IDSelected = -1;
          btnDelete.setVisibility(4);
          break;
        }
      case R.id.clear:
        {
          // 清空屏幕
          clearScreen();
          break;
        }
      default:
        {
          //			mMapControl.getMap().refresh();

        }
    }
  }