Conflicts:
	collect-library/src/main/java/com/navinfo/collect/library/map/source/OMDBTileDataSource.java
This commit is contained in:
qiji4215
2023-08-04 10:15:17 +08:00
30 changed files with 728 additions and 121 deletions

View File

@@ -1,6 +1,5 @@
package com.navinfo.collect.library.data.entity
import com.navinfo.collect.library.system.Constant
import com.navinfo.collect.library.utils.GeometryTools
import com.navinfo.collect.library.utils.GeometryToolsKt
import io.realm.RealmDictionary
@@ -8,9 +7,7 @@ import io.realm.RealmObject
import io.realm.RealmSet
import io.realm.annotations.Ignore
import io.realm.annotations.PrimaryKey
import org.locationtech.jts.geom.Coordinate
import org.locationtech.jts.geom.Geometry
import org.oscim.core.MercatorProjection
import java.util.*
/**

View File

@@ -216,11 +216,11 @@ class LayerManagerHandler(context: AppCompatActivity, mapView: NIMapView, traceP
labelNiLocationLayer.isEnabled = false
}
fun omdbLayersUpdate(){
// omdbVectorTileLayer
fun omdbLayersClear(){
// omdbVectorTileLayer.
// omdbReferenceTileLayer.
omdbLabelLayer.update()
omdbReferenceLabelLayer.update()
omdbLabelLayer.clearLabels()
omdbReferenceLabelLayer.clearLabels()
}
}

View File

@@ -1,6 +1,7 @@
package com.navinfo.collect.library.map.source;
import android.os.Build;
import android.util.Log;
import androidx.annotation.RequiresApi;
@@ -29,27 +30,28 @@ 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) {
int m = Constant.OVER_ZOOM-tile.zoomLevel;
int xStart = (int)tile.tileX<<m;
int xEnd = (int)((tile.tileX+1)<<m);
int yStart = (int)tile.tileY<<m;
int yEnd = (int)((tile.tileY+1)<<m);
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);
int yStart = (int) tile.tileY << m;
int yEnd = (int) ((tile.tileY + 1) << m);
Log.e("jingo", Constant.TASK_ID + " " + xStart + " " + xEnd + " " + yStart + " " + yEnd);
RealmQuery<ReferenceEntity> realmQuery = Realm.getDefaultInstance().where(ReferenceEntity.class)
.rawPredicate("tileX>="+xStart+" and tileX<="+xEnd+" and tileY>="+yStart+" and tileY<="+yEnd);
.rawPredicate("taskId=" + Constant.TASK_ID + " and tileX>=" + xStart + " and tileX<=" + xEnd + " and tileY>=" + yStart + " and tileY<=" + yEnd);
// 筛选不显示的数据
if (Constant.HAD_LAYER_INVISIABLE_ARRAY!=null&&Constant.HAD_LAYER_INVISIABLE_ARRAY.length>0) {
if (Constant.HAD_LAYER_INVISIABLE_ARRAY != null && Constant.HAD_LAYER_INVISIABLE_ARRAY.length > 0) {
realmQuery.beginGroup();
for (String type: Constant.HAD_LAYER_INVISIABLE_ARRAY) {
for (String type : Constant.HAD_LAYER_INVISIABLE_ARRAY) {
realmQuery.notEqualTo("table", type);
}
realmQuery.endGroup();
}
List<ReferenceEntity> listResult = realmQuery/*.distinct("id")*/.findAll();
if (!listResult.isEmpty()) {
mThreadLocalDecoders.get().decode(tile.zoomLevel,tile, mapDataSink, listResult);
mThreadLocalDecoders.get().decode(tile.zoomLevel, tile, mapDataSink, listResult);
}
Log.e("jingo",listResult.size() + "条数据");
mapDataSink.completed(QueryResult.SUCCESS);
// Log.d("RealmDBTileDataSource", "tile:"+tile.getBoundingBox().toString());
} else {

View File

@@ -38,7 +38,7 @@ 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);
Log.e("jingo", Constant.TASK_ID + " " + xStart + " " + xEnd + " " + yStart + " " + yEnd);
RealmQuery<RenderEntity> realmQuery = Realm.getDefaultInstance().where(RenderEntity.class).rawPredicate("tileX>=" + xStart + " and tileX<=" + xEnd + " and tileY>=" + yStart + " and tileY<=" + yEnd+ " and visable=1");
// 筛选不显示的数据
if (Constant.HAD_LAYER_INVISIABLE_ARRAY != null && Constant.HAD_LAYER_INVISIABLE_ARRAY.length > 0) {
@@ -50,9 +50,10 @@ public class OMDBTileDataSource implements ITileDataSource {
}
List<RenderEntity> listResult = realmQuery/*.distinct("id")*/.findAll();
if (!listResult.isEmpty()) {
Log.e("qj","查询数据=="+listResult.size()+"==地图级别"+tile.zoomLevel);
mThreadLocalDecoders.get().decode(tile.zoomLevel,tile, mapDataSink, listResult);
Log.e("qj", "查询数据==" + listResult.size() + "==地图级别" + tile.zoomLevel);
mThreadLocalDecoders.get().decode(tile.zoomLevel, tile, mapDataSink, listResult);
}
Log.e("jingo",listResult.size() + "条数据 主");
mapDataSink.completed(QueryResult.SUCCESS);
// Log.d("RealmDBTileDataSource", "tile:"+tile.getBoundingBox().toString());
} else {

View File

@@ -41,7 +41,7 @@ public class RealmDBTileDataSource implements ITileDataSource {
int yStart = (int)tile.tileY<<m;
int yEnd = (int)((tile.tileY+1)<<m);
RealmQuery<GeometryFeatureEntity> realmQuery = Realm.getInstance(RealmUtils.getInstance().getRealmConfiguration()).where(GeometryFeatureEntity.class)
RealmQuery<GeometryFeatureEntity> realmQuery = Realm.getDefaultInstance().where(GeometryFeatureEntity.class)
.rawPredicate("tileX>="+xStart+" and tileX<="+xEnd+" and tileY>="+yStart+" and tileY<="+yEnd);
// 筛选不显示的数据
if (Constant.HAD_LAYER_INVISIABLE_ARRAY!=null&&Constant.HAD_LAYER_INVISIABLE_ARRAY.length>0) {

View File

@@ -17,10 +17,10 @@ public class Constant {
public static String MAP_PATH = Environment.getExternalStorageDirectory() + "/map/";
public static void setVisibleTypeMap(Map<String, Boolean> visibleTypeMap) {
Map<String, Boolean> HD_LAYER_VISIABLE_MAP= new HashMap<>();
Map<String, Boolean> HD_LAYER_VISIABLE_MAP = new HashMap<>();
// 只记录不显示的类型
if (visibleTypeMap!=null&&!visibleTypeMap.isEmpty()) {
for (Map.Entry<String, Boolean> e:visibleTypeMap.entrySet()) {
if (visibleTypeMap != null && !visibleTypeMap.isEmpty()) {
for (Map.Entry<String, Boolean> e : visibleTypeMap.entrySet()) {
if (!e.getValue()) {
HD_LAYER_VISIABLE_MAP.put(e.getKey(), e.getValue());
}
@@ -28,11 +28,13 @@ public class Constant {
}
HAD_LAYER_INVISIABLE_ARRAY = HD_LAYER_VISIABLE_MAP.keySet().toArray(new String[HD_LAYER_VISIABLE_MAP.keySet().size()]);
}
public static String[] HAD_LAYER_INVISIABLE_ARRAY;
public static final int OVER_ZOOM = 22;
public static final int MAX_ZOOM = 22;
public static final int OMDB_MIN_ZOOM = 16;
public static int TASK_ID = -1;
/**
* 服务器地址
*/