Browse Source

点击查询

zhouyuexiang 1 year ago
parent
commit
a60ec32663
23 changed files with 102 additions and 14 deletions
  1. 102 14
      tile-service/src/main/java/cn/com/taiji/tile/util/ShapeUtils.java
  2. BIN
      tile-service/src/main/resources/images/gis-layout-tools_example-aj.png
  3. BIN
      tile-service/src/main/resources/images/gis-layout-tools_example-axcbypyj.png
  4. BIN
      tile-service/src/main/resources/images/gis-layout-tools_example-bg.png
  5. BIN
      tile-service/src/main/resources/images/gis-layout-tools_example-czw.png
  6. BIN
      tile-service/src/main/resources/images/gis-layout-tools_example-fzs.png
  7. BIN
      tile-service/src/main/resources/images/gis-layout-tools_example-galsb.png
  8. BIN
      tile-service/src/main/resources/images/gis-layout-tools_example-ggcsfxyf.png
  9. BIN
      tile-service/src/main/resources/images/gis-layout-tools_example-hajc.png
  10. BIN
      tile-service/src/main/resources/images/gis-layout-tools_example-hcz.png
  11. BIN
      tile-service/src/main/resources/images/gis-layout-tools_example-jgzzmgs.png
  12. BIN
      tile-service/src/main/resources/images/gis-layout-tools_example-jq.png
  13. BIN
      tile-service/src/main/resources/images/gis-layout-tools_example-jsj.png
  14. BIN
      tile-service/src/main/resources/images/gis-layout-tools_example-lg.png
  15. BIN
      tile-service/src/main/resources/images/gis-layout-tools_example-lgsjkyfl.png
  16. BIN
      tile-service/src/main/resources/images/gis-layout-tools_example-lgszyjkscsb.png
  17. BIN
      tile-service/src/main/resources/images/gis-layout-tools_example-mylsb.png
  18. BIN
      tile-service/src/main/resources/images/gis-layout-tools_example-qyfxfk.png
  19. BIN
      tile-service/src/main/resources/images/gis-layout-tools_example-shlsb.png
  20. BIN
      tile-service/src/main/resources/images/gis-layout-tools_example-shzlfxfk.png
  21. BIN
      tile-service/src/main/resources/images/gis-layout-tools_example-wgy.png
  22. BIN
      tile-service/src/main/resources/images/gis-layout-tools_example-wxcl.png
  23. BIN
      tile-service/src/main/resources/images/gis-layout-tools_example-xfjy.png

+ 102 - 14
tile-service/src/main/java/cn/com/taiji/tile/util/ShapeUtils.java

@@ -14,6 +14,7 @@ import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.util.List;
 import java.util.Objects;
+import java.util.concurrent.CopyOnWriteArrayList;
 
 /**
  * @author zzyx 2024/1/5
@@ -34,20 +35,24 @@ public class ShapeUtils {
      */
     public static byte[] getTileByte(String bboxStr, List<POI> dataList, ShapeStyle shapeStyle) {
         BufferedImage image = new BufferedImage(WIDTH, HEIGHT, BufferedImage.TYPE_INT_ARGB);
-        String[] split = bboxStr.split(",");
-        double[] bbox = new double[split.length];
-        Graphics2D graphics = image.createGraphics();
-        for (POI poi : dataList) {
-            Geometry shape = GeoUtils.getGeoUtils().createGeometry(poi.getShape());
-            //判断数据点线面
-            if (StringUtils.equals(shape.getGeometryType(), "Polygon")) {
-                drawPolygonShape(bbox, graphics, shape, poi, shapeStyle);
-            } else if (StringUtils.equalsAny(shape.getGeometryType(), "LinearRing", "LineString", "MultiLineString")) {
-                drawLineShape(bbox, graphics, shape, shapeStyle);
-            } else if (StringUtils.equals(shape.getGeometryType(), "Point")) {
-                drawPointShape(bbox, graphics, shape, poi, shapeStyle);
-            }
-        }
+//        String[] split = bboxStr.split(",");
+//        double[] bbox = new double[split.length];
+//        for (int i = 0; i < split.length; i++) {
+//            bbox[i] = Double.parseDouble(split[i]);
+//        }
+//        Graphics2D graphics = image.createGraphics();
+//        for (POI poi : dataList) {
+//            Geometry shape = GeoUtils.getGeoUtils().createGeometry(poi.getShape());
+//            //判断数据点线面
+//            if (StringUtils.equals(shape.getGeometryType(), "Polygon")) {
+//                drawPolygonShape(bbox, graphics, shape, poi, shapeStyle);
+//            } else if (StringUtils.equalsAny(shape.getGeometryType(), "LinearRing", "LineString", "MultiLineString")) {
+//                drawLineShape(bbox, graphics, shape, shapeStyle);
+//            } else if (StringUtils.equals(shape.getGeometryType(), "Point")) {
+//                drawPointShape(bbox, graphics, shape, poi, shapeStyle);
+//            }
+//        }
+        renderAndDetectClick(image, bboxStr, dataList, shapeStyle, 0, 0, null, false);
         ByteArrayOutputStream buffer = new ByteArrayOutputStream();
         try {
             ImageIO.write(image, "png", buffer);
@@ -251,5 +256,88 @@ public class ShapeUtils {
         }
     }
 
+    public static List<POI> detectClick(String bboxStr, List<POI> dataList, ShapeStyle shapeStyle, int x, int y) {
+        List<POI> clickSelectedDataList = new CopyOnWriteArrayList<>();
+//        renderAndDetectClick(image, bboxStr, dataList, shapeStyle, x, y, clickSelectedDataList, true);
+        String[] split = bboxStr.split(",");
+        double[] bbox = new double[split.length];
+        for (int i = 0; i < split.length; i++) {
+            bbox[i] = Double.parseDouble(split[i]);
+        }
+        dataList.parallelStream().forEach(poi -> {
+            BufferedImage image = new BufferedImage(WIDTH, HEIGHT, BufferedImage.TYPE_INT_ARGB);
+            Graphics2D graphics = image.createGraphics();
+            Geometry shape = GeoUtils.getGeoUtils().createGeometry(poi.getShape());
+//            //判断数据点线面
+            if (StringUtils.equals(shape.getGeometryType(), "Polygon")) {
+                drawPolygonShape(bbox, graphics, shape, poi, shapeStyle);
+            } else if (StringUtils.equalsAny(shape.getGeometryType(), "LinearRing", "LineString", "MultiLineString")) {
+                drawLineShape(bbox, graphics, shape, shapeStyle);
+            } else if (StringUtils.equals(shape.getGeometryType(), "Point")) {
+                drawPointShape(bbox, graphics, shape, poi, shapeStyle);
+            }
+            //如果选中
+            int rgb = image.getRGB(x, y);
+            System.out.println("rgb---->" + image.getRGB(x, y));
+            int alpha = (rgb >> 24) & 0xff; // 提取alpha值
+//                System.out.println("RGB->"+alpha);
+            if (alpha > 0) {
+                // 像素被填充
+                clickSelectedDataList.add(poi);
+            }
+        });
+        return clickSelectedDataList;
+    }
+
+    public static void renderAndDetectClick(BufferedImage image, String bboxStr, List<POI> dataList, ShapeStyle shapeStyle, int x, int y, List<POI> clickSelectedDataList, Boolean isClick) {
+        String[] split = bboxStr.split(",");
+        double[] bbox = new double[split.length];
+        for (int i = 0; i < split.length; i++) {
+            bbox[i] = Double.parseDouble(split[i]);
+        }
+        Graphics2D graphics = image.createGraphics();
+        dataList.parallelStream().forEach(poi -> {
+            Geometry shape = GeoUtils.getGeoUtils().createGeometry(poi.getShape());
+//            //判断数据点线面
+            if (StringUtils.equals(shape.getGeometryType(), "Polygon")) {
+                drawPolygonShape(bbox, graphics, shape, poi, shapeStyle);
+            } else if (StringUtils.equalsAny(shape.getGeometryType(), "LinearRing", "LineString", "MultiLineString")) {
+                drawLineShape(bbox, graphics, shape, shapeStyle);
+            } else if (StringUtils.equals(shape.getGeometryType(), "Point")) {
+                drawPointShape(bbox, graphics, shape, poi, shapeStyle);
+            }
+            if (BooleanUtil.isTrue(isClick)) {
+                //如果选中
+                int rgb = image.getRGB(x, y);
+                System.out.println("rgb---->" + image.getRGB(x, y));
+                int alpha = (rgb >> 24) & 0xff; // 提取alpha值
+//                System.out.println("RGB->"+alpha);
+                if (alpha > 0) {
+                    // 像素被填充
+                    clickSelectedDataList.add(poi);
+                }
+            }
+        });
+//        for (POI poi : dataList) {
+//            Geometry shape = GeoUtils.getGeoUtils().createGeometry(poi.getShape());
+//            //判断数据点线面
+//            if (StringUtils.equals(shape.getGeometryType(), "Polygon")) {
+//                drawPolygonShape(bbox, graphics, shape, poi, shapeStyle);
+//            } else if (StringUtils.equalsAny(shape.getGeometryType(), "LinearRing", "LineString", "MultiLineString")) {
+//                drawLineShape(bbox, graphics, shape, shapeStyle);
+//            } else if (StringUtils.equals(shape.getGeometryType(), "Point")) {
+//                drawPointShape(bbox, graphics, shape, poi, shapeStyle);
+//            }
+//            if (BooleanUtil.isTrue(isClick)) {
+//                //如果选中
+//                int rgb = image.getRGB(x, y);
+//                int alpha = (rgb >> 24) & 0xff; // 提取alpha值
+//                if (alpha > 0) {
+//                    // 像素被填充
+//                    clickSelectedDataList.add(poi);
+//                }
+//            }
+//        }
+    }
 
 }

BIN
tile-service/src/main/resources/images/gis-layout-tools_example-aj.png


BIN
tile-service/src/main/resources/images/gis-layout-tools_example-axcbypyj.png


BIN
tile-service/src/main/resources/images/gis-layout-tools_example-bg.png


BIN
tile-service/src/main/resources/images/gis-layout-tools_example-czw.png


BIN
tile-service/src/main/resources/images/gis-layout-tools_example-fzs.png


BIN
tile-service/src/main/resources/images/gis-layout-tools_example-galsb.png


BIN
tile-service/src/main/resources/images/gis-layout-tools_example-ggcsfxyf.png


BIN
tile-service/src/main/resources/images/gis-layout-tools_example-hajc.png


BIN
tile-service/src/main/resources/images/gis-layout-tools_example-hcz.png


BIN
tile-service/src/main/resources/images/gis-layout-tools_example-jgzzmgs.png


BIN
tile-service/src/main/resources/images/gis-layout-tools_example-jq.png


BIN
tile-service/src/main/resources/images/gis-layout-tools_example-jsj.png


BIN
tile-service/src/main/resources/images/gis-layout-tools_example-lg.png


BIN
tile-service/src/main/resources/images/gis-layout-tools_example-lgsjkyfl.png


BIN
tile-service/src/main/resources/images/gis-layout-tools_example-lgszyjkscsb.png


BIN
tile-service/src/main/resources/images/gis-layout-tools_example-mylsb.png


BIN
tile-service/src/main/resources/images/gis-layout-tools_example-qyfxfk.png


BIN
tile-service/src/main/resources/images/gis-layout-tools_example-shlsb.png


BIN
tile-service/src/main/resources/images/gis-layout-tools_example-shzlfxfk.png


BIN
tile-service/src/main/resources/images/gis-layout-tools_example-wgy.png


BIN
tile-service/src/main/resources/images/gis-layout-tools_example-wxcl.png


BIN
tile-service/src/main/resources/images/gis-layout-tools_example-xfjy.png