This commit is contained in:
qiji4215
2023-09-13 10:22:01 +08:00
7 changed files with 63 additions and 128 deletions

View File

@@ -61,7 +61,7 @@ class ImportPreProcess {
) { ) {
var angle = renderEntity?.properties?.get("angle")?.toDouble()!! var angle = renderEntity?.properties?.get("angle")?.toDouble()!!
// angle角度为与正北方向的顺时针夹角将其转换为与X轴正方向的逆时针夹角即为正东方向的夹角 // angle角度为与正北方向的顺时针夹角将其转换为与X轴正方向的逆时针夹角即为正东方向的夹角
angle = -((450 - angle) % 360) angle = ((450 - angle) % 360)
radian = Math.toRadians(angle) radian = Math.toRadians(angle)
} else { } else {
var isReverse = false // 是否为逆向 var isReverse = false // 是否为逆向
@@ -138,7 +138,7 @@ class ImportPreProcess {
// angle += 180 // angle += 180
// } // }
// angle角度为与正北方向的顺时针夹角将其转换为与X轴正方向的逆时针夹角即为正东方向的夹角 // angle角度为与正北方向的顺时针夹角将其转换为与X轴正方向的逆时针夹角即为正东方向的夹角
angle = -((450 - angle) % 360) angle = ((450 - angle) % 360)
radian = Math.toRadians(angle) radian = Math.toRadians(angle)
} else if (Geometry.TYPENAME_LINESTRING == geometry?.geometryType) { } else if (Geometry.TYPENAME_LINESTRING == geometry?.geometryType) {
var coordinates = geometry.coordinates var coordinates = geometry.coordinates
@@ -327,7 +327,7 @@ class ImportPreProcess {
"angle" "angle"
)?.toDouble()!! )?.toDouble()!!
// angle角度为与正北方向的顺时针夹角将其转换为与X轴正方向的逆时针夹角即为正东方向的夹角 // angle角度为与正北方向的顺时针夹角将其转换为与X轴正方向的逆时针夹角即为正东方向的夹角
angle = -((450 - angle) % 360) angle = ((450 - angle) % 360)
radian = Math.toRadians(angle) radian = Math.toRadians(angle)
} else if (Geometry.TYPENAME_LINESTRING == geometry?.geometryType) { } else if (Geometry.TYPENAME_LINESTRING == geometry?.geometryType) {
var coordinates = geometry.coordinates var coordinates = geometry.coordinates
@@ -351,7 +351,7 @@ class ImportPreProcess {
} }
} else renderEntity?.properties?.get("angle")?.toDouble()!! } else renderEntity?.properties?.get("angle")?.toDouble()!!
angle = -((450 - angle) % 360) angle = ((450 - angle) % 360)
radian = Math.toRadians(angle) radian = Math.toRadians(angle)
} }
@@ -735,7 +735,7 @@ class ImportPreProcess {
"angle" "angle"
)?.toDouble()!! )?.toDouble()!!
// angle角度为与正北方向的顺时针夹角将其转换为与X轴正方向的逆时针夹角即为正东方向的夹角 // angle角度为与正北方向的顺时针夹角将其转换为与X轴正方向的逆时针夹角即为正东方向的夹角
angle = -((450 - angle) % 360) angle = ((450 - angle) % 360)
radian = Math.toRadians(angle) radian = Math.toRadians(angle)
} else if (Geometry.TYPENAME_LINESTRING == geometry?.geometryType) { } else if (Geometry.TYPENAME_LINESTRING == geometry?.geometryType) {
var coordinates = geometry.coordinates var coordinates = geometry.coordinates
@@ -756,7 +756,7 @@ class ImportPreProcess {
} }
} else renderEntity?.properties?.get("angle")?.toDouble()!! } else renderEntity?.properties?.get("angle")?.toDouble()!!
angle = -((450 - angle) % 360) angle = ((450 - angle) % 360)
radian = Math.toRadians(angle) radian = Math.toRadians(angle)
} }

View File

@@ -1620,14 +1620,6 @@
<symbol repeat="false" repeat-start="0" rotate="false" <symbol repeat="false" repeat-start="0" rotate="false"
src="assets:omdb/icon_4023_0.svg" symbol-height="56" symbol-width="56"></symbol> src="assets:omdb/icon_4023_0.svg" symbol-height="56" symbol-width="56"></symbol>
</m> </m>
<!-- <m k="type" v="angle">
<symbol repeat="false" repeat-gap="2000" repeat-start="0" rotate="true"
src="assets:omdb/icon_arrow_right.svg" symbol-height="64"
symbol-width="64"></symbol>
</m>
<m k="type" v="s_2_e">
<line use="s2e" />
</m>-->
</m> </m>
<!-- 道路边界类型 --> <!-- 道路边界类型 -->
<m v="OMDB_RDBOUND_BOUNDARYTYPE"> <m v="OMDB_RDBOUND_BOUNDARYTYPE">
@@ -1921,13 +1913,13 @@
<!--电子眼--> <!--电子眼-->
<m v="OMDB_ELECTRONICEYE"> <m v="OMDB_ELECTRONICEYE">
<m k="eleceyeId"> <m k="eleceyeId">
<caption dy="-30" fill="#0000FF" k="name" priority="0" size="12" <caption dy="-12" fill="#ffffff" k="name" priority="0" size="11"
stroke="#ffffff" stroke-width="1.0"></caption> stroke="#000000" stroke-width="1.0" bg-fill="#F98F03"></caption>
<symbol repeat="false" src="assets:omdb/4010/icon_electroniceye_4010.svg" symbol-height="44" symbol-width="44"></symbol> <symbol repeat="false" src="assets:omdb/4010/icon_electroniceye_4010.svg" symbol-height="44" symbol-width="44"></symbol>
</m> </m>
<m k="type" v="angle"> <m k="type" v="angle">
<symbol repeat="false" repeat-gap="2000" repeat-start="0" rotate="true" <symbol repeat="false" repeat-gap="2000" repeat-start="0" rotate="true"
src="assets:omdb/4010/right.svg" symbol-height="40" symbol-width="40"></symbol> src="assets:omdb/icon_arrow_right.svg" symbol-height="54" symbol-width="54"></symbol>
</m> </m>
<m k="type" v="s_2_e"> <m k="type" v="s_2_e">
<line use="s2e" /> <line use="s2e" />

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 6.7 KiB

After

Width:  |  Height:  |  Size: 5.5 KiB

View File

@@ -7,14 +7,17 @@ import androidx.annotation.RequiresApi;
import com.navinfo.collect.library.data.entity.ReferenceEntity; import com.navinfo.collect.library.data.entity.ReferenceEntity;
import com.navinfo.collect.library.system.Constant; import com.navinfo.collect.library.system.Constant;
import com.navinfo.collect.library.utils.GeometryTools;
import com.navinfo.collect.library.utils.MapParamUtils; import com.navinfo.collect.library.utils.MapParamUtils;
import org.locationtech.jts.geom.Polygon;
import org.oscim.layers.tile.MapTile; import org.oscim.layers.tile.MapTile;
import org.oscim.tiling.ITileDataSink; import org.oscim.tiling.ITileDataSink;
import org.oscim.tiling.ITileDataSource; import org.oscim.tiling.ITileDataSource;
import org.oscim.tiling.QueryResult; import org.oscim.tiling.QueryResult;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
import io.realm.Realm; import io.realm.Realm;
import io.realm.RealmQuery; import io.realm.RealmQuery;
@@ -33,7 +36,7 @@ public class OMDBReferenceDataSource implements ITileDataSource {
@Override @Override
public void query(MapTile tile, ITileDataSink mapDataSink) { public void query(MapTile tile, ITileDataSink mapDataSink) {
// 获取tile对应的坐标范围 // 获取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 m = Constant.OVER_ZOOM - tile.zoomLevel;
int xStart = (int) tile.tileX << m; int xStart = (int) tile.tileX << m;
int xEnd = (int) ((tile.tileX + 1) << m); int xEnd = (int) ((tile.tileX + 1) << m);
@@ -66,12 +69,16 @@ public class OMDBReferenceDataSource implements ITileDataSource {
} }
List<ReferenceEntity> listResult = realmQuery/*.distinct("id")*/.findAll(); List<ReferenceEntity> listResult = realmQuery/*.distinct("id")*/.findAll();
if (!listResult.isEmpty()) { 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); 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(); Realm.getInstance(MapParamUtils.getTaskConfig()).close();
} else { } else {
mapDataSink.completed(QueryResult.SUCCESS); mapDataSink.completed(QueryResult.TILE_NOT_FOUND);
} }
} }

View File

@@ -7,14 +7,17 @@ import androidx.annotation.RequiresApi;
import com.navinfo.collect.library.data.entity.RenderEntity; import com.navinfo.collect.library.data.entity.RenderEntity;
import com.navinfo.collect.library.system.Constant; import com.navinfo.collect.library.system.Constant;
import com.navinfo.collect.library.utils.GeometryTools;
import com.navinfo.collect.library.utils.MapParamUtils; import com.navinfo.collect.library.utils.MapParamUtils;
import org.locationtech.jts.geom.Polygon;
import org.oscim.layers.tile.MapTile; import org.oscim.layers.tile.MapTile;
import org.oscim.tiling.ITileDataSink; import org.oscim.tiling.ITileDataSink;
import org.oscim.tiling.ITileDataSource; import org.oscim.tiling.ITileDataSource;
import org.oscim.tiling.QueryResult; import org.oscim.tiling.QueryResult;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
import io.realm.Realm; import io.realm.Realm;
import io.realm.RealmQuery; import io.realm.RealmQuery;
@@ -32,7 +35,7 @@ public class OMDBTileDataSource implements ITileDataSource {
@Override @Override
public void query(MapTile tile, ITileDataSink mapDataSink) { public void query(MapTile tile, ITileDataSink mapDataSink) {
// 获取tile对应的坐标范围 // 获取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 m = Constant.OVER_ZOOM - tile.zoomLevel;
int xStart = (int) tile.tileX << m; int xStart = (int) tile.tileX << m;
int xEnd = (int) ((tile.tileX + 1) << m); int xEnd = (int) ((tile.tileX + 1) << m);
@@ -62,13 +65,18 @@ public class OMDBTileDataSource implements ITileDataSource {
realmQuery.endGroup(); realmQuery.endGroup();
} }
List<RenderEntity> listResult = realmQuery/*.distinct("id")*/.findAll(); List<RenderEntity> listResult = realmQuery/*.distinct("id")*/.findAll();
// 数据记录的tile号是以正外接tile号列表此处过滤并未与当前tile相交的数据
if (!listResult.isEmpty()) { 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); 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(); Realm.getInstance(MapParamUtils.getTaskConfig()).close();
} else { } else {
mapDataSink.completed(QueryResult.SUCCESS); mapDataSink.completed(QueryResult.TILE_NOT_FOUND);
} }
} }

View File

@@ -18,6 +18,8 @@ import org.locationtech.jts.geom.Polygon;
import org.locationtech.jts.io.WKTReader; import org.locationtech.jts.io.WKTReader;
import org.locationtech.jts.operation.linemerge.LineMerger; import org.locationtech.jts.operation.linemerge.LineMerger;
import org.oscim.core.GeoPoint; import org.oscim.core.GeoPoint;
import org.oscim.core.MercatorProjection;
import org.oscim.core.Tile;
import org.oscim.map.Map; import org.oscim.map.Map;
import java.math.BigDecimal; import java.math.BigDecimal;
@@ -257,6 +259,22 @@ public class GeometryTools {
return gon.toString(); 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)); double radianDegree = 2 * Math.asin(Math.sin(radianDistance / 2) / Math.cos(radianLatitude));
return Math.toDegrees(radianDegree); 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)});
}
/** /**
* 经纬度转墨卡托 * 经纬度转墨卡托
*/ */

2
vtm

Submodule vtm updated: 3ea6a7c906...d1ac330cf7