优化数据安装效率,更换压缩库及不进行车道中心线转化面业务
This commit is contained in:
@@ -3,6 +3,7 @@ package com.navinfo.collect.library.data.entity
|
||||
import android.util.Log
|
||||
import com.google.gson.Gson
|
||||
import com.google.gson.reflect.TypeToken
|
||||
import com.navinfo.collect.library.utils.DeflaterUtil
|
||||
import com.navinfo.collect.library.utils.GeometryTools
|
||||
import com.navinfo.collect.library.utils.GeometryToolsKt
|
||||
import com.navinfo.collect.library.utils.StrZipUtil
|
||||
@@ -24,7 +25,7 @@ open class ReferenceEntity() : RealmObject() {
|
||||
@Ignore
|
||||
lateinit var name: String //要素名
|
||||
lateinit var table: String //要素表名
|
||||
var propertiesDb: String = ""
|
||||
var propertiesDb: ByteArray? = null
|
||||
var code: String = "0" // 要素编码
|
||||
|
||||
@Ignore
|
||||
@@ -79,11 +80,11 @@ open class ReferenceEntity() : RealmObject() {
|
||||
@Ignore
|
||||
var properties: RealmDictionary<String> = RealmDictionary()
|
||||
get() {
|
||||
if (propertiesDb.isNotEmpty() && field.isEmpty()) {
|
||||
if (propertiesDb!=null && field.isEmpty()) {
|
||||
try {
|
||||
val gson = Gson()
|
||||
val type = object : TypeToken<RealmDictionary<String>>() {}.type
|
||||
field = gson.fromJson(StrZipUtil.uncompress(propertiesDb), type)
|
||||
field = gson.fromJson(DeflaterUtil.decompress(propertiesDb).toString(), type)
|
||||
} catch (e: Exception) {
|
||||
Log.e("jingo","ReferenceEntity 转 properties $e")
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import android.util.Log
|
||||
import com.google.gson.Gson
|
||||
import com.google.gson.reflect.TypeToken
|
||||
import com.navinfo.collect.library.system.Constant
|
||||
import com.navinfo.collect.library.utils.DeflaterUtil
|
||||
import com.navinfo.collect.library.utils.GeometryTools
|
||||
import com.navinfo.collect.library.utils.GeometryToolsKt
|
||||
import com.navinfo.collect.library.utils.StrZipUtil
|
||||
@@ -31,7 +32,7 @@ open class RenderEntity() : RealmObject(), Parcelable {
|
||||
lateinit var name: String //要素名
|
||||
lateinit var table: String //要素表名
|
||||
var code: String = "0" // 要素编码
|
||||
var propertiesDb: String = ""
|
||||
var propertiesDb: ByteArray? = null
|
||||
var geometry: String =
|
||||
"" // 要素渲染参考的geometry,该数据可能会在导入预处理环节被修改,原始geometry会保存在properties的geometry字段下
|
||||
get() {
|
||||
@@ -82,11 +83,11 @@ open class RenderEntity() : RealmObject(), Parcelable {
|
||||
@Ignore
|
||||
var properties: RealmDictionary<String> = RealmDictionary()
|
||||
get() {
|
||||
if (propertiesDb != null && propertiesDb.isNotEmpty() && field.isEmpty()) {
|
||||
if (propertiesDb != null && field.isEmpty()) {
|
||||
try {
|
||||
val gson = Gson()
|
||||
val type = object : TypeToken<RealmDictionary<String>>() {}.type
|
||||
field = gson.fromJson(StrZipUtil.uncompress(propertiesDb), type)
|
||||
field = gson.fromJson(DeflaterUtil.decompress(propertiesDb).toString(), type)
|
||||
} catch (e: Exception) {
|
||||
Log.e("jingo","RenderEntity 转 properties $e")
|
||||
}
|
||||
|
||||
@@ -190,6 +190,37 @@ class MarkHandler(context: AppCompatActivity, mapView: NIMapView) :
|
||||
layer
|
||||
}
|
||||
|
||||
/**
|
||||
* 评测精简数据marker 图层
|
||||
*/
|
||||
private val niLocationItemizedLayerRough: ItemizedLayer by lazy {
|
||||
|
||||
val symbol = MarkerSymbol(niLocationBitmap, MarkerSymbol.HotspotPlace.CENTER)
|
||||
val layerRough = ItemizedLayer(
|
||||
mapView.vtmMap,
|
||||
symbol,
|
||||
)
|
||||
layerRough.setOnItemGestureListener(object : OnItemGestureListener<MarkerInterface> {
|
||||
override fun onItemSingleTapUp(index: Int, item: MarkerInterface?): Boolean {
|
||||
val tag = mMapView.listenerTagList.last()
|
||||
val listenerList = mMapView.listenerList[tag]
|
||||
if (listenerList != null) {
|
||||
for (listener in listenerList) {
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
override fun onItemLongPress(index: Int, item: MarkerInterface?): Boolean {
|
||||
return true
|
||||
}
|
||||
|
||||
})
|
||||
layerRough.isEnabled = false
|
||||
addLayer(layerRough, NIMapView.LAYER_GROUPS.OPERATE_MARKER)
|
||||
layerRough
|
||||
}
|
||||
|
||||
/**
|
||||
* 评测精简数据marker 图层
|
||||
*/
|
||||
@@ -206,14 +237,6 @@ class MarkHandler(context: AppCompatActivity, mapView: NIMapView) :
|
||||
val listenerList = mMapView.listenerList[tag]
|
||||
if (listenerList != null) {
|
||||
for (listener in listenerList) {
|
||||
/* if (listener is OnNiLocationItemListener) {
|
||||
listener.onNiLocation(
|
||||
tag,
|
||||
index,
|
||||
(niLocationItemizedLayerSimple.itemList[index] as MarkerItem).uid as NiLocation
|
||||
)
|
||||
break
|
||||
}*/
|
||||
}
|
||||
}
|
||||
return true
|
||||
@@ -333,11 +356,13 @@ class MarkHandler(context: AppCompatActivity, mapView: NIMapView) :
|
||||
qsRecordItemizedLayer.isEnabled = false
|
||||
}
|
||||
if (traceMarkerEnable) {
|
||||
niLocationItemizedLayer.isEnabled = mapPosition.getZoomLevel() in 17..20
|
||||
niLocationItemizedLayerSimple.isEnabled = mapPosition.getZoomLevel() in 12..16
|
||||
niLocationItemizedLayer.isEnabled = mapPosition.getZoomLevel() in 18..20
|
||||
niLocationItemizedLayerSimple.isEnabled = mapPosition.getZoomLevel() in 14..17
|
||||
niLocationItemizedLayerRough.isEnabled = mapPosition.getZoomLevel() in 12..13
|
||||
} else {
|
||||
niLocationItemizedLayer.isEnabled = false
|
||||
niLocationItemizedLayerSimple.isEnabled = false
|
||||
niLocationItemizedLayerRough.isEnabled = false
|
||||
}
|
||||
}
|
||||
})
|
||||
@@ -450,9 +475,11 @@ class MarkHandler(context: AppCompatActivity, mapView: NIMapView) :
|
||||
fun setTraceMarkEnable(enable: Boolean) {
|
||||
niLocationItemizedLayer.isEnabled = enable
|
||||
niLocationItemizedLayerSimple.isEnabled = enable
|
||||
niLocationItemizedLayerRough.isEnabled = enable
|
||||
traceMarkerEnable = enable
|
||||
niLocationItemizedLayer.populate()
|
||||
niLocationItemizedLayerSimple.populate()
|
||||
niLocationItemizedLayerRough.populate()
|
||||
mMapView.updateMap(true)
|
||||
}
|
||||
|
||||
@@ -604,6 +631,15 @@ class MarkHandler(context: AppCompatActivity, mapView: NIMapView) :
|
||||
niLocationItemizedLayerSimple.update()
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加质检数据marker
|
||||
*/
|
||||
fun addNiLocationMarkerItemRough(niLocation: NiLocation) {
|
||||
var geoMarkerItem = createNILocationBitmap(niLocation)
|
||||
niLocationItemizedLayerRough.addItem(geoMarkerItem)
|
||||
niLocationItemizedLayerRough.update()
|
||||
}
|
||||
|
||||
private fun createNILocationBitmap(niLocation: NiLocation): MarkerItem {
|
||||
|
||||
val direction: Double = niLocation.direction
|
||||
@@ -870,6 +906,8 @@ class MarkHandler(context: AppCompatActivity, mapView: NIMapView) :
|
||||
niLocationItemizedLayer.update()
|
||||
niLocationItemizedLayerSimple.removeAllItems()
|
||||
niLocationItemizedLayerSimple.update()
|
||||
niLocationItemizedLayerRough.removeAllItems()
|
||||
niLocationItemizedLayerRough.update()
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -896,6 +934,18 @@ class MarkHandler(context: AppCompatActivity, mapView: NIMapView) :
|
||||
}
|
||||
}
|
||||
|
||||
fun getNILocationItemizedLayerRoughSize(): Int {
|
||||
return niLocationItemizedLayerRough.itemList.size
|
||||
}
|
||||
|
||||
fun getNILocationRough(index: Int): NiLocation? {
|
||||
return if (index > -1 && index < getNILocationItemizedLayerRoughSize()) {
|
||||
((niLocationItemizedLayerRough.itemList[index]) as MarkerItem).uid as NiLocation
|
||||
} else {
|
||||
null
|
||||
}
|
||||
}
|
||||
|
||||
fun getNILocation(index: Int): NiLocation? {
|
||||
return if (index > -1 && index < getNILocationItemizedLayerSize()) {
|
||||
((niLocationItemizedLayer.itemList[index]) as MarkerItem).uid as NiLocation
|
||||
|
||||
@@ -4,10 +4,13 @@ import static org.oscim.core.MercatorProjection.latitudeToY;
|
||||
import static org.oscim.core.MercatorProjection.longitudeToX;
|
||||
|
||||
import android.os.Build;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.RequiresApi;
|
||||
|
||||
import com.navinfo.collect.library.data.entity.ReferenceEntity;
|
||||
import com.navinfo.collect.library.enums.DataCodeEnum;
|
||||
import com.navinfo.collect.library.utils.GeometryTools;
|
||||
|
||||
import org.locationtech.jts.geom.Coordinate;
|
||||
import org.locationtech.jts.geom.Geometry;
|
||||
@@ -100,7 +103,14 @@ public class OMDBReferenceDecoder extends TileDecoder {
|
||||
processCoordinateArray(multiPoint.getGeometryN(i).getCoordinates(), false);
|
||||
}
|
||||
} else if (geometry instanceof LineString) {
|
||||
processLineString((LineString) geometry);
|
||||
//将车道中心进行转化面渲染
|
||||
if(layerName== DataCodeEnum.OMDB_LANE_LINK_LG.name()){
|
||||
Log.e("qj","车道中心线转化开始");
|
||||
processPolygon((Polygon)GeometryTools.createGeometry(GeometryTools.computeLine(0.000035,0.000035,geometry.toString())));
|
||||
Log.e("qj","车道中心线转化结束");
|
||||
}else{
|
||||
processLineString((LineString) geometry);
|
||||
}
|
||||
} else if (geometry instanceof MultiLineString) {
|
||||
MultiLineString multiLineString = (MultiLineString) geometry;
|
||||
for (int i = 0; i < multiLineString.getNumGeometries(); i++) {
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
package com.navinfo.collect.library.utils;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.zip.Deflater;
|
||||
import java.util.zip.Inflater;
|
||||
|
||||
public class DeflaterUtil {
|
||||
|
||||
private DeflaterUtil() {
|
||||
|
||||
}
|
||||
|
||||
private static final int BUFFER_SIZE = 8192;
|
||||
|
||||
public static byte[] compress(byte[] bytes) {
|
||||
if (bytes == null) {
|
||||
throw new NullPointerException("bytes is null");
|
||||
}
|
||||
int lenght = 0;
|
||||
Deflater deflater = new Deflater();
|
||||
deflater.setInput(bytes);
|
||||
deflater.finish();
|
||||
byte[] outputBytes = new byte[BUFFER_SIZE];
|
||||
try (ByteArrayOutputStream bos = new ByteArrayOutputStream()) {
|
||||
while (!deflater.finished()) {
|
||||
lenght = deflater.deflate(outputBytes);
|
||||
bos.write(outputBytes, 0, lenght);
|
||||
}
|
||||
deflater.end();
|
||||
return bos.toByteArray();
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException("Deflater compress error", e);
|
||||
}
|
||||
}
|
||||
|
||||
public static byte[] decompress(byte[] bytes) {
|
||||
if (bytes == null) {
|
||||
throw new NullPointerException("bytes is null");
|
||||
}
|
||||
int length = 0;
|
||||
Inflater inflater = new Inflater();
|
||||
inflater.setInput(bytes);
|
||||
byte[] outputBytes = new byte[BUFFER_SIZE];
|
||||
try (ByteArrayOutputStream bos = new ByteArrayOutputStream();) {
|
||||
while (!inflater.finished()) {
|
||||
length = inflater.inflate(outputBytes);
|
||||
if (length == 0) {
|
||||
break;
|
||||
}
|
||||
bos.write(outputBytes, 0, length);
|
||||
}
|
||||
inflater.end();
|
||||
return bos.toByteArray();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("Deflater decompress error", e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user