diff --git a/app/src/main/java/com/navinfo/omqs/db/ImportPreProcess.kt b/app/src/main/java/com/navinfo/omqs/db/ImportPreProcess.kt index c9aee110..7cf7dca1 100644 --- a/app/src/main/java/com/navinfo/omqs/db/ImportPreProcess.kt +++ b/app/src/main/java/com/navinfo/omqs/db/ImportPreProcess.kt @@ -61,7 +61,7 @@ class ImportPreProcess { ) { var angle = renderEntity?.properties?.get("angle")?.toDouble()!! // angle角度为与正北方向的顺时针夹角,将其转换为与X轴正方向的逆时针夹角,即为正东方向的夹角 - angle = -((450 - angle) % 360) + angle = ((450 - angle) % 360) radian = Math.toRadians(angle) } else { var isReverse = false // 是否为逆向 @@ -138,7 +138,7 @@ class ImportPreProcess { // angle += 180 // } // angle角度为与正北方向的顺时针夹角,将其转换为与X轴正方向的逆时针夹角,即为正东方向的夹角 - angle = -((450 - angle) % 360) + angle = ((450 - angle) % 360) radian = Math.toRadians(angle) } else if (Geometry.TYPENAME_LINESTRING == geometry?.geometryType) { var coordinates = geometry.coordinates @@ -327,7 +327,7 @@ class ImportPreProcess { "angle" )?.toDouble()!! // angle角度为与正北方向的顺时针夹角,将其转换为与X轴正方向的逆时针夹角,即为正东方向的夹角 - angle = -((450 - angle) % 360) + angle = ((450 - angle) % 360) radian = Math.toRadians(angle) } else if (Geometry.TYPENAME_LINESTRING == geometry?.geometryType) { var coordinates = geometry.coordinates @@ -351,7 +351,7 @@ class ImportPreProcess { } } else renderEntity?.properties?.get("angle")?.toDouble()!! - angle = -((450 - angle) % 360) + angle = ((450 - angle) % 360) radian = Math.toRadians(angle) } @@ -735,7 +735,7 @@ class ImportPreProcess { "angle" )?.toDouble()!! // angle角度为与正北方向的顺时针夹角,将其转换为与X轴正方向的逆时针夹角,即为正东方向的夹角 - angle = -((450 - angle) % 360) + angle = ((450 - angle) % 360) radian = Math.toRadians(angle) } else if (Geometry.TYPENAME_LINESTRING == geometry?.geometryType) { var coordinates = geometry.coordinates @@ -756,7 +756,7 @@ class ImportPreProcess { } } else renderEntity?.properties?.get("angle")?.toDouble()!! - angle = -((450 - angle) % 360) + angle = ((450 - angle) % 360) radian = Math.toRadians(angle) } diff --git a/collect-library/src/main/assets/editormarker.xml b/collect-library/src/main/assets/editormarker.xml index cb9bbb5f..6b5f15ba 100644 --- a/collect-library/src/main/assets/editormarker.xml +++ b/collect-library/src/main/assets/editormarker.xml @@ -1620,14 +1620,6 @@ - @@ -1921,13 +1913,13 @@ - + + src="assets:omdb/icon_arrow_right.svg" symbol-height="54" symbol-width="54"> diff --git a/collect-library/src/main/assets/omdb/4010/icon_electroniceye_4010.svg b/collect-library/src/main/assets/omdb/4010/icon_electroniceye_4010.svg index 122a28af..cb0c181d 100644 --- a/collect-library/src/main/assets/omdb/4010/icon_electroniceye_4010.svg +++ b/collect-library/src/main/assets/omdb/4010/icon_electroniceye_4010.svg @@ -1,103 +1 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file + \ No newline at end of file diff --git a/collect-library/src/main/java/com/navinfo/collect/library/map/source/OMDBReferenceDataSource.java b/collect-library/src/main/java/com/navinfo/collect/library/map/source/OMDBReferenceDataSource.java index 01ec8393..46ea1749 100644 --- a/collect-library/src/main/java/com/navinfo/collect/library/map/source/OMDBReferenceDataSource.java +++ b/collect-library/src/main/java/com/navinfo/collect/library/map/source/OMDBReferenceDataSource.java @@ -7,14 +7,17 @@ import androidx.annotation.RequiresApi; import com.navinfo.collect.library.data.entity.ReferenceEntity; import com.navinfo.collect.library.system.Constant; +import com.navinfo.collect.library.utils.GeometryTools; import com.navinfo.collect.library.utils.MapParamUtils; +import org.locationtech.jts.geom.Polygon; import org.oscim.layers.tile.MapTile; import org.oscim.tiling.ITileDataSink; import org.oscim.tiling.ITileDataSource; import org.oscim.tiling.QueryResult; import java.util.List; +import java.util.stream.Collectors; import io.realm.Realm; import io.realm.RealmQuery; @@ -33,7 +36,7 @@ public class OMDBReferenceDataSource implements ITileDataSource { @Override public void query(MapTile tile, ITileDataSink mapDataSink) { // 获取tile对应的坐标范围 - if (tile.zoomLevel >= Constant.OMDB_MIN_ZOOM && tile.zoomLevel <= Constant.OVER_ZOOM) { + if (tile.zoomLevel >= Constant.OMDB_MIN_ZOOM && tile.zoomLevel < Constant.OVER_ZOOM) { int m = Constant.OVER_ZOOM - tile.zoomLevel; int xStart = (int) tile.tileX << m; int xEnd = (int) ((tile.tileX + 1) << m); @@ -66,12 +69,16 @@ public class OMDBReferenceDataSource implements ITileDataSource { } List listResult = realmQuery/*.distinct("id")*/.findAll(); if (!listResult.isEmpty()) { + Polygon tilePolygon = GeometryTools.getTilePolygon(tile); + listResult = listResult.stream().filter((ReferenceEntity referenceEntity) -> referenceEntity.getWkt().intersects(tilePolygon)).collect(Collectors.toList()); mThreadLocalDecoders.get().decode(tile.zoomLevel, tile, mapDataSink, listResult); + mapDataSink.completed(QueryResult.SUCCESS); + } else { + mapDataSink.completed(QueryResult.TILE_NOT_FOUND); } - mapDataSink.completed(QueryResult.SUCCESS); Realm.getInstance(MapParamUtils.getTaskConfig()).close(); } else { - mapDataSink.completed(QueryResult.SUCCESS); + mapDataSink.completed(QueryResult.TILE_NOT_FOUND); } } diff --git a/collect-library/src/main/java/com/navinfo/collect/library/map/source/OMDBTileDataSource.java b/collect-library/src/main/java/com/navinfo/collect/library/map/source/OMDBTileDataSource.java index b06dca9a..78f106ef 100644 --- a/collect-library/src/main/java/com/navinfo/collect/library/map/source/OMDBTileDataSource.java +++ b/collect-library/src/main/java/com/navinfo/collect/library/map/source/OMDBTileDataSource.java @@ -7,14 +7,17 @@ import androidx.annotation.RequiresApi; import com.navinfo.collect.library.data.entity.RenderEntity; import com.navinfo.collect.library.system.Constant; +import com.navinfo.collect.library.utils.GeometryTools; import com.navinfo.collect.library.utils.MapParamUtils; +import org.locationtech.jts.geom.Polygon; import org.oscim.layers.tile.MapTile; import org.oscim.tiling.ITileDataSink; import org.oscim.tiling.ITileDataSource; import org.oscim.tiling.QueryResult; import java.util.List; +import java.util.stream.Collectors; import io.realm.Realm; import io.realm.RealmQuery; @@ -32,7 +35,7 @@ public class OMDBTileDataSource implements ITileDataSource { @Override public void query(MapTile tile, ITileDataSink mapDataSink) { // 获取tile对应的坐标范围 - if (tile.zoomLevel >= Constant.OMDB_MIN_ZOOM && tile.zoomLevel <= Constant.OVER_ZOOM) { + if (tile.zoomLevel >= Constant.OMDB_MIN_ZOOM && tile.zoomLevel < Constant.OVER_ZOOM) { int m = Constant.OVER_ZOOM - tile.zoomLevel; int xStart = (int) tile.tileX << m; int xEnd = (int) ((tile.tileX + 1) << m); @@ -62,13 +65,18 @@ public class OMDBTileDataSource implements ITileDataSource { realmQuery.endGroup(); } List listResult = realmQuery/*.distinct("id")*/.findAll(); + // 数据记录的tile号是以正外接tile号列表,此处过滤并未与当前tile相交的数据 if (!listResult.isEmpty()) { + Polygon tilePolygon = GeometryTools.getTilePolygon(tile); + listResult = listResult.stream().filter((RenderEntity renderEntity) -> renderEntity.getWkt().intersects(tilePolygon)).collect(Collectors.toList()); mThreadLocalDecoders.get().decode(tile.zoomLevel, tile, mapDataSink, listResult); + mapDataSink.completed(QueryResult.SUCCESS); + } else { + mapDataSink.completed(QueryResult.TILE_NOT_FOUND); } - mapDataSink.completed(QueryResult.SUCCESS); Realm.getInstance(MapParamUtils.getTaskConfig()).close(); } else { - mapDataSink.completed(QueryResult.SUCCESS); + mapDataSink.completed(QueryResult.TILE_NOT_FOUND); } } diff --git a/collect-library/src/main/java/com/navinfo/collect/library/utils/GeometryTools.java b/collect-library/src/main/java/com/navinfo/collect/library/utils/GeometryTools.java index 4ac644d2..05011a0d 100644 --- a/collect-library/src/main/java/com/navinfo/collect/library/utils/GeometryTools.java +++ b/collect-library/src/main/java/com/navinfo/collect/library/utils/GeometryTools.java @@ -18,6 +18,8 @@ import org.locationtech.jts.geom.Polygon; import org.locationtech.jts.io.WKTReader; import org.locationtech.jts.operation.linemerge.LineMerger; import org.oscim.core.GeoPoint; +import org.oscim.core.MercatorProjection; +import org.oscim.core.Tile; import org.oscim.map.Map; import java.math.BigDecimal; @@ -257,6 +259,22 @@ public class GeometryTools { return gon.toString(); } + /** + * 创建多边形几何 + * + * @param coords [] + * @return Geometry + */ + public static Polygon createPolygonFromCoords(Coordinate[] coords) { + GeometryFactory factory = new GeometryFactory(); + + Polygon gon = factory.createPolygon(coords); + + if (gon == null) + return null; + return gon; + } + /** * 创建多边形几何 * @@ -1607,7 +1625,19 @@ public class GeometryTools { double radianDegree = 2 * Math.asin(Math.sin(radianDistance / 2) / Math.cos(radianLatitude)); return Math.toDegrees(radianDegree); } - + /** + * 获取指定tile对应的polygon面 + * @param tile vtm中的瓦片 + * */ + public static Polygon getTilePolygon(Tile tile) { + // 获取当前tile的起点坐标 + double startLongitude = MercatorProjection.tileXToLongitude(tile.tileX, tile.zoomLevel); + double startLatitude = MercatorProjection.tileYToLatitude(tile.tileY, tile.zoomLevel); + double endLongitude = MercatorProjection.tileXToLongitude(tile.tileX + 1, tile.zoomLevel); + double endLatitude = MercatorProjection.tileYToLatitude(tile.tileY + 1, tile.zoomLevel); + return GeometryTools.createPolygonFromCoords(new Coordinate[]{new Coordinate(startLongitude, startLongitude), new Coordinate(endLongitude, startLatitude), + new Coordinate(endLongitude, endLatitude), new Coordinate(startLongitude, endLatitude), new Coordinate(startLongitude, startLongitude)}); + } /** * 经纬度转墨卡托 */ diff --git a/vtm b/vtm index 3ea6a7c9..d1ac330c 160000 --- a/vtm +++ b/vtm @@ -1 +1 @@ -Subproject commit 3ea6a7c90627e6e8ea10b3896004d9082167a7ff +Subproject commit d1ac330cf7a8727bb2065093e72d60521775ba6d