fix: 解决冲突

This commit is contained in:
2023-09-13 10:19:44 +08:00
41 changed files with 1135 additions and 399 deletions

View File

@@ -185,7 +185,7 @@
width="0.1" />
<!--道路形态-->
<style-line dasharray="8,2,2,2,2,2" id="road_morphology" repeat-gap="3" repeat-start="0" stroke="#1afa29" width="0.3" />
<style-line dasharray="8,2,2,2,2,2" id="road_morphology" repeat-gap="3" repeat-start="0" stroke="#1afa29" width="0.4" />
<!--###### ASSIGNMENT ######-->
@@ -1491,41 +1491,48 @@
</m>
<m k="qi_table">
<!-- 道路线 -->
<m v="OMDB_RD_LINK">
<line stroke="#9c9c9c" width="1" />
<line stroke="#9c9c9c" width="0.5" />
</m>
<!--道路种别-->
<m v="OMDB_RD_LINK_KIND">
<outline-layer id="kind0" stroke="#44000000" width="0.1" />
<outline-layer id="kind1" stroke="#aa807040" width="0.1" />
<outline-layer id="kind0" stroke="#44000000" width="0.8" fix="true"/>
<outline-layer id="kind1" stroke="#aa807040" width="0.8" fix="true"/>
<m k="kind" v="1">
<line blur="0.3" outline="kind0" use="highway:z11" />
<line blur="0.3" outline="kind0" use="highway:z11" width="3.5" fix="true"/>
</m>
<m k="kind" v="2|3">
<line outline="kind0" use="trunk" />
<line outline="kind0" use="trunk" fix="true" width="2.6"/>
</m>
<m k="kind" v="4">
<line outline="kind0" use="primary:z11" />
<m k="kind" v="4">width="0.4"
<line outline="kind0" use="primary:z11" fix="true" width="2.2"/>
</m>
<m k="kind" v="5|6">
<line outline="kind0" use="secondary:z11" />
<line outline="kind0" use="secondary:z11" fix="true" width="1.5"/>
</m>
<m k="kind" v="7">
<line outline="kind0" use="tertiary" />
<line outline="kind0" use="tertiary" fix="true" width="2.2"/>
</m>
<m k="kind" v="8">
<line outline="kind0" use="residential" />
<line outline="kind0" use="residential" fix="true" width="0.5"/>
</m>
<m k="kind" v="9|10">
<line outline="kind0" use="footway:z17" />
<line outline="kind0" use="footway:z17" fix="true" width="0.7"/>
</m>
<m k="kind" v="11|13">
<line outline="kind0" use="ferry" />
<line outline="kind0" use="ferry" fix="true" width="5"/>
</m>
<m k="kind" v="15">
<line outline="kind0" use="highway:cycleway" />
<line outline="kind0" use="highway:cycleway" width="1"/>
</m>
</m>

View File

@@ -62,7 +62,7 @@ open class RenderEntity() : RealmObject(), Parcelable {
var zoomMin: Int = 18 //显示最小级别
var zoomMax: Int = 23 //显示最大级别
var enable:Int = 0 // 默认0不是显示 1为渲染显示 2为常显
var catchEnable:Int = 0 // 0捕捉 1捕捉
var catchEnable:Int = 0 // 0捕捉 1捕捉
constructor(name: String) : this() {
this.name = name

View File

@@ -735,7 +735,7 @@ public final class NIMapView extends RelativeLayout {
if (mapView != null && mapView.map() != null)
return mapView.map().getMapPosition().getZoomLevel();
return 0;
return 16;
}
/**

View File

@@ -146,6 +146,7 @@ class LayerManagerHandler(context: AppCompatActivity, mapView: NIMapView, traceP
// 添加显示grid的tile号的图层
tileGridLayer = TileGridLayer(mMapView.vtmMap)
addLayer(tileGridLayer, NIMapView.LAYER_GROUPS.OPERATE_MARKER)
tileGridLayer.isEnabled = false
}
private fun resetOMDBVectorTileLayer() {

View File

@@ -28,7 +28,7 @@ class LineHandler(context: AppCompatActivity, mapView: NIMapView) : BaseHandler(
//高亮线绘制线 样式
val defaultLineStyle = Style.builder()
.stippleColor(context.resources.getColor(R.color.draw_line_blue2_color))
.strokeWidth(10f)
.strokeWidth(5f)
.fillColor(context.resources.getColor(R.color.teal_200))
.fillAlpha(0.5f)
.strokeColor(context.resources.getColor(R.color.teal_200))

View File

@@ -67,7 +67,10 @@ class LocationLayerHandler(context: AppCompatActivity, mapView: NIMapView) :
val errorCode = it.locType
mCurrentLocation = it
mLocationLayer.setPosition(it.latitude, it.longitude, it.radius)
Log.e("qj", "location==${it.longitude}==errorCode===$errorCode===${it.locTypeDescription}")
Log.e(
"qj",
"location==${it.longitude}==errorCode===$errorCode===${it.locTypeDescription}"
)
getCurrentNiLocation()?.let { it1 ->
mContext.lifecycleScope.launch {
@@ -212,6 +215,7 @@ private class MyLocationListener(callback: (BDLocation) -> Unit) : BDAbstractLoc
val call = callback;
override fun onReceiveLocation(location: BDLocation) {
call(location)
Log.e("jingo", "定位结果:速度=" + location.speed +" 方向=" + location.direction)
}
}

View File

@@ -42,12 +42,14 @@ public class OMDBReferenceDataSource implements ITileDataSource {
int xEnd = (int) ((tile.tileX + 1) << m);
int yStart = (int) tile.tileY << m;
int yEnd = (int) ((tile.tileY + 1) << m);
if(isUpdate){
Realm.getDefaultInstance().refresh();
Realm.getInstance(MapParamUtils.getTaskConfig()).refresh();
isUpdate = false;
}
String sql = "taskId="+ MapParamUtils.getTaskId() +" and tileX>=" + xStart + " and tileX<=" + xEnd + " and tileY>=" + yStart + " and tileY<=" + yEnd + "";
String sql = " tileX>=" + xStart + " and tileX<=" + xEnd + " and tileY>=" + yStart + " and tileY<=" + yEnd + "";
if(MapParamUtils.getDataLayerEnum()!=null){
sql += " and enable" + MapParamUtils.getDataLayerEnum().getSql();
@@ -55,7 +57,7 @@ public class OMDBReferenceDataSource implements ITileDataSource {
sql += " and 1=1";
}
RealmQuery<ReferenceEntity> realmQuery = Realm.getDefaultInstance().where(ReferenceEntity.class)
RealmQuery<ReferenceEntity> realmQuery = Realm.getInstance(MapParamUtils.getTaskConfig()).where(ReferenceEntity.class)
.rawPredicate(sql);
// 筛选不显示的数据
if (Constant.HAD_LAYER_INVISIABLE_ARRAY != null && Constant.HAD_LAYER_INVISIABLE_ARRAY.length > 0) {
@@ -74,7 +76,7 @@ public class OMDBReferenceDataSource implements ITileDataSource {
} else {
mapDataSink.completed(QueryResult.TILE_NOT_FOUND);
}
// Log.d("RealmDBTileDataSource", "tile:"+tile.getBoundingBox().toString());
Realm.getInstance(MapParamUtils.getTaskConfig()).close();
} else {
mapDataSink.completed(QueryResult.TILE_NOT_FOUND);
}

View File

@@ -41,12 +41,13 @@ public class OMDBTileDataSource implements ITileDataSource {
int xEnd = (int) ((tile.tileX + 1) << m);
int yStart = (int) tile.tileY << m;
int yEnd = (int) ((tile.tileY + 1) << m);
if(isUpdate){
Realm.getDefaultInstance().refresh();
Realm.getInstance(MapParamUtils.getTaskConfig()).refresh();
isUpdate = false;
}
String sql = "taskId="+ MapParamUtils.getTaskId() +" and tileX>=" + xStart + " and tileX<=" + xEnd + " and tileY>=" + yStart + " and tileY<=" + yEnd + "";
String sql =" tileX>=" + xStart + " and tileX<=" + xEnd + " and tileY>=" + yStart + " and tileY<=" + yEnd + "";
if(MapParamUtils.getDataLayerEnum()!=null){
sql += " and enable" + MapParamUtils.getDataLayerEnum().getSql();
@@ -54,7 +55,7 @@ public class OMDBTileDataSource implements ITileDataSource {
sql += " and 1=1";
}
RealmQuery<RenderEntity> realmQuery = Realm.getDefaultInstance().where(RenderEntity.class).rawPredicate(sql);
RealmQuery<RenderEntity> realmQuery = Realm.getInstance(MapParamUtils.getTaskConfig()).where(RenderEntity.class).rawPredicate(sql);
// 筛选不显示的数据
if (Constant.HAD_LAYER_INVISIABLE_ARRAY != null && Constant.HAD_LAYER_INVISIABLE_ARRAY.length > 0) {
realmQuery.beginGroup();
@@ -73,6 +74,7 @@ public class OMDBTileDataSource implements ITileDataSource {
} else {
mapDataSink.completed(QueryResult.TILE_NOT_FOUND);
}
Realm.getInstance(MapParamUtils.getTaskConfig()).close();
} else {
mapDataSink.completed(QueryResult.TILE_NOT_FOUND);
}

View File

@@ -54,6 +54,7 @@ public class RealmDBTileDataSource implements ITileDataSource {
List<GeometryFeatureEntity> listResult = realmQuery.distinct("id").findAll();
mThreadLocalDecoders.get().decode(tile, mapDataSink, listResult);
mapDataSink.completed(QueryResult.SUCCESS);
Realm.getDefaultInstance().close();
// Log.d("RealmDBTileDataSource", "tile:"+tile.getBoundingBox().toString());
} else {
mapDataSink.completed(QueryResult.SUCCESS);

View File

@@ -1,8 +1,12 @@
package com.navinfo.collect.library.utils;
import android.graphics.Point;
import android.os.Build;
import android.util.Log;
import org.jetbrains.annotations.NotNull;
import org.locationtech.jts.algorithm.distance.DistanceToPoint;
import org.locationtech.jts.algorithm.distance.PointPairDistance;
import org.locationtech.jts.geom.Coordinate;
import org.locationtech.jts.geom.Geometry;
import org.locationtech.jts.geom.GeometryFactory;
@@ -436,7 +440,7 @@ public class GeometryTools {
Geometry startGeo = createGeometry(startGeoPoint);
Geometry endGeo = createGeometry(endGeoPoint);
double d = startGeo.distance(endGeo);
return convertDistanceToDegree(d,startGeoPoint.getLatitude());
return convertDistanceToDegree(d, startGeoPoint.getLatitude());
}
return 0;
@@ -609,6 +613,21 @@ public class GeometryTools {
return list;
}
public static List<GeoPoint> getGeoPoints(Geometry geometry) {
List<GeoPoint> list = null;
if (geometry != null) {
Coordinate[] coordinates = geometry.getCoordinates();
if (coordinates != null && coordinates.length > 0) {
list = new ArrayList<GeoPoint>();
for (Coordinate coor : coordinates) {
list.add(new GeoPoint(coor.y, coor.x));
}
}
}
return list;
}
public static Coordinate[] getCoordinates(String str) {
Coordinate[] coordinates = null;
if (Check.isEmpty(str))
@@ -1314,6 +1333,8 @@ public class GeometryTools {
}
public enum SNAP_TYPE {
/**
* 像素
@@ -1347,7 +1368,7 @@ public class GeometryTools {
}
public static boolean isCheckError(double lon, double lat) {
if(lon==0||lat==0){
if (lon == 0 || lat == 0) {
return true;
}
@@ -1397,8 +1418,10 @@ public class GeometryTools {
static class Check {
public static boolean isEmpty(String str) {
if (str == null || str.isEmpty()) {
return true;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) {
if (str == null || str.isEmpty()) {
return true;
}
}
return false;
}
@@ -1466,7 +1489,7 @@ public class GeometryTools {
switch (unit) {
case SNAP_PIXEL:
org.oscim.core.Point p = new org.oscim.core.Point();
fMap.viewport().toScreenPoint(gp,false, p);
fMap.viewport().toScreenPoint(gp, false, p);
GeoPoint gPLq = fMap.viewport().fromScreenPoint((float) p.x, (float) p.y);
org.oscim.core.Point pL = new org.oscim.core.Point((p.x - distance), (p.y - distance));
@@ -1541,6 +1564,7 @@ public class GeometryTools {
/**
* 计算距离
*
* @param list
* @return
*/
@@ -1593,20 +1617,80 @@ public class GeometryTools {
* @return 对应的地理坐标系中的距离(单位:度)
*/
private static final double EARTH_RADIUS = 6371000.0;
public static double convertDistanceToDegree(double distance, double latitude) {
double radianDistance = distance / EARTH_RADIUS;
double radianLatitude = Math.toRadians(latitude);
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);
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)});
}
/**
* 经纬度转墨卡托
*/
public static Coordinate geoPointToMercator(GeoPoint point) {
Coordinate coordinate = new Coordinate();
double x = point.getLongitude() * 20037508.34 / 180;
double y = Math.log(Math.tan((90 + point.getLatitude()) * Math.PI / 360)) / (Math.PI / 180);
y = y * 20037508.34 / 180;
coordinate.x = x;
coordinate.y = y;
return coordinate;
}
/**
* 墨卡托转经纬度
*/
public static GeoPoint mercatorToGeoPoint(Coordinate coordinate) {
GeoPoint point = null;
double x = coordinate.x / 20037508.34 * 180;
double y = coordinate.y / 20037508.34 * 180;
y = 180 / Math.PI * (2 * Math.atan(Math.exp(y * Math.PI / 180)) - Math.PI / 2);
point = new GeoPoint(y, x);
return point;
}
public static List<GeoPoint> pointToLineDistance(GeoPoint point, List<GeoPoint> pointList) {
Coordinate coordinate = geoPointToMercator(point);
Coordinate[] cs = new Coordinate[pointList.size()];
for (int i = 0; i < pointList.size(); i++) {
Coordinate c = geoPointToMercator(pointList.get(i));
cs[i] = c;
}
GeometryFactory factory = new GeometryFactory();
LineString lineString = factory.createLineString(cs);
PointPairDistance pointPairDistance = new PointPairDistance();
DistanceToPoint.computeDistance(
lineString,
coordinate,
pointPairDistance
);
List newPoints = new ArrayList<GeoPoint>();
for (int i = 0; i < pointPairDistance.getCoordinates().length; i++) {
newPoints.add(mercatorToGeoPoint(pointPairDistance.getCoordinate(i)));
}
return newPoints;
}
}

View File

@@ -2,20 +2,33 @@ package com.navinfo.collect.library.utils;
import com.navinfo.collect.library.enums.DataLayerEnum;
import java.io.File;
import io.realm.RealmConfiguration;
public class MapParamUtils {
private static int mtaskId = -1;
private static RealmConfiguration mTaskConfig = null;
private static DataLayerEnum dataLayerEnum = DataLayerEnum.ONLY_ENABLE_LAYERS;
public static int getTaskId() {
return mtaskId;
}
public static void setTaskId(int taskId) {
mtaskId = taskId;
}
public static RealmConfiguration getTaskConfig() {
return mTaskConfig;
}
public static void setTaskConfig(RealmConfiguration taskConfig) {
mTaskConfig = taskConfig;
}
public static DataLayerEnum getDataLayerEnum() {
return dataLayerEnum;
}