矩形选

@Override
		public void OnGeometrySelected(int count) {
			pointList = new ArrayList<PointInfoModel>();
			int c = m_myMapWnd.GetMap().Selection().GetCount();
			System.out.println("c=" + c);
			for (int i = 0; i < c; i++) {
				eMyResultSet rs = m_myMapWnd.GetMap().Selection().GetAt(i);
				System.out.println("所属层名:" + rs.GetLayer().GetName());
				rs.Reset();
				while (rs.HasNext()) {
					eMyPoint point = rs.GetGeometry().GetPointAt(0);// 获取逻辑坐标
					eMyPoint2D point2D = m_myMapWnd.GetMap().MapToGeo(point);// 转物理坐标
					x = point2D.GetX();
					y = point2D.GetY();
					pointInfo = new PointInfoModel();
					pointInfo.setX(x);
					pointInfo.setY(y);
					pointInfo.setName(rs.GetString(0).toString());
					pointInfo.setId(rs.GetString(1).toString());
					pointInfo.setCity(rs.GetString(2).toString());
					pointInfo.setArea(rs.GetString(3).toString());
					pointInfo.setCategory(rs.GetString(4).toString());
					pointInfo.setGeocode(rs.GetString(5).toString());

					pointList.add(pointInfo);

				}
			}

			// 输出显示结果
			String text = "";
			if (pointList.size() > 0) {
				// 点选
				if (pointList.size() == 1) {
					for (int i = 0; i < pointList.size(); i++) {
						double x = pointList.get(i).getX();
						double y = pointList.get(i).getY();
						String name = pointList.get(i).getName();
						String id = pointList.get(i).getId();
						String city = pointList.get(i).getCity();
						String area = pointList.get(i).getArea();
						String category = pointList.get(i).getCategory();
						String geocode = pointList.get(i).getGeocode();

						int j = i + 1;
						System.out.println("---------" + j + "---------");
						String xy = "物理坐标:(" + x + "),(" + y + ")";
						System.out.println(xy);
						System.out.println("名称:" + name);
						System.out.println("ID:" + id);
						System.out.println("城市:" + city);
						System.out.println("所在区:" + area);
						System.out.println("类别码:" + category);
						System.out.println("地理编码:" + geocode);
						System.out.println("---------------------------------");

						text += "名称:" + name + "\n";
						text += "ID:" + id + "\n";
						text += "城市:" + city + "\n";
						text += "所在区:" + area + "\n";
						text += "类别码:" + category + "\n";
						text += "地理编码:" + geocode + "\n";
						text += "物理坐标:(" + x + "),(" + y + ")" + "\n";

					}
				}
				// 多选
				else {
					for (int i = 0; i < pointList.size(); i++) {
						double x = pointList.get(i).getX();
						double y = pointList.get(i).getY();
						String name = pointList.get(i).getName();
						String id = pointList.get(i).getId();
						String city = pointList.get(i).getCity();
						String area = pointList.get(i).getArea();
						String category = pointList.get(i).getCategory();
						String geocode = pointList.get(i).getGeocode();

						int j = i + 1;
						System.out.println("---------" + j + "---------");
						System.out.println("物理坐标:(" + x + "),(" + y + ")");
						System.out.println("名称:" + name);
						System.out.println("ID:" + id);
						System.out.println("城市:" + city);
						System.out.println("所在区:" + area);
						System.out.println("类别码:" + category);
						System.out.println("地理编码:" + geocode);
						System.out.println("---------------------------------");
						text += name + "\n";
					}
					
				}

			}
			Toast.makeText(Demo.this, text, 9000).show();
		}

 

你可能感兴趣的:(矩形选)