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; }
@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(); } } }