优化数据安装效率,更换第三方库

This commit is contained in:
qiji4215 2023-10-31 15:02:21 +08:00
parent 584eea6928
commit 0f97c08b44
7 changed files with 86 additions and 46 deletions

View File

@ -150,7 +150,7 @@
"code": 2092, "code": 2092,
"name": "车道类型", "name": "车道类型",
"catch": true, "catch": true,
"isDependOnOtherTable": true, "isDependOnOtherTable": false,
"zoomMin": 18, "zoomMin": 18,
"zoomMax": 20, "zoomMax": 20,
"transformer": [ "transformer": [
@ -173,7 +173,7 @@
"name": "桥", "name": "桥",
"catch": true, "catch": true,
"existSubCode": true, "existSubCode": true,
"isDependOnOtherTable": true, "isDependOnOtherTable": false,
"zoomMin": 15, "zoomMin": 15,
"zoomMax": 20, "zoomMax": 20,
"transformer": [ "transformer": [
@ -350,7 +350,7 @@
"code": 4001, "code": 4001,
"name": "路口", "name": "路口",
"zoomMin": 15, "zoomMin": 15,
"isDependOnOtherTable": true, "isDependOnOtherTable": false,
"zoomMax": 17, "zoomMax": 17,
"catch": true, "catch": true,
"transformer": [ "transformer": [
@ -452,7 +452,7 @@
"zoomMin": 15, "zoomMin": 15,
"zoomMax": 17, "zoomMax": 17,
"filterData": true, "filterData": true,
"isDependOnOtherTable": true, "isDependOnOtherTable": false,
"catch": true, "catch": true,
"transformer": [ "transformer": [
{ {
@ -492,7 +492,7 @@
"code": 4009, "code": 4009,
"name": "警示信息", "name": "警示信息",
"catch": true, "catch": true,
"isDependOnOtherTable": true, "isDependOnOtherTable": false,
"zoomMin": 15, "zoomMin": 15,
"zoomMax": 20, "zoomMax": 20,
"transformer": [ "transformer": [
@ -581,7 +581,7 @@
"code": 4601, "code": 4601,
"name": "车信", "name": "车信",
"catch": true, "catch": true,
"isDependOnOtherTable": true, "isDependOnOtherTable": false,
"zoomMin": 15, "zoomMin": 15,
"zoomMax": 17, "zoomMax": 17,
"transformer": [ "transformer": [
@ -610,7 +610,7 @@
"code": 5001, "code": 5001,
"name": "车道中心线", "name": "车道中心线",
"catch": false, "catch": false,
"isDependOnOtherTable": true, "isDependOnOtherTable": false,
"checkLinkId": false, "checkLinkId": false,
"zoomMin": 18, "zoomMin": 18,
"zoomMax": 20, "zoomMax": 20,

View File

@ -247,11 +247,11 @@ class ImportOMDBHelper @AssistedInject constructor(
CMLog.writeLogtoFile(ImportOMDBHelper::class.java.name, "数据安装", "安装结束") CMLog.writeLogtoFile(ImportOMDBHelper::class.java.name, "数据安装", "安装结束")
Constant.INSTALL_DATA = false
} catch (e: Exception) { } catch (e: Exception) {
Log.e("jingo", "安装报错1 ${e.message}") Log.e("jingo", "安装报错1 ${e.message}")
return false return false
}finally {
Constant.INSTALL_DATA = false
} }
return true return true
} }
@ -294,12 +294,15 @@ class ImportOMDBHelper @AssistedInject constructor(
continue continue
} }
newTime = System.currentTimeMillis() newTime = System.currentTimeMillis()
Log.e(
"jingo", if(elementIndex%50==0){
"安装数据 ${currentConfig.table} $elementIndex ${listRenderEntity.size} ${newTime - time}" Log.e("jingo", "安装数据 ${currentConfig.table} $elementIndex ${listRenderEntity.size} ${newTime - time}")
) }
time = newTime time = newTime
elementIndex += 1 elementIndex += 1
val map = gson.fromJson<Map<String, Any>>( val map = gson.fromJson<Map<String, Any>>(
line, object : TypeToken<Map<String, Any>>() {}.type line, object : TypeToken<Map<String, Any>>() {}.type
).toMutableMap() ).toMutableMap()
@ -488,6 +491,8 @@ class ImportOMDBHelper @AssistedInject constructor(
// 对renderEntity做预处理后再保存 // 对renderEntity做预处理后再保存
val resultEntity = importConfig.transformProperties(renderEntity, realm) val resultEntity = importConfig.transformProperties(renderEntity, realm)
//车道中心线不在主表写入
if (resultEntity != null) { if (resultEntity != null) {
//对code编码需要特殊处理 存在多个属性值时渲染优先级SA>PA,存在多个属性值时渲染优先级FRONTAGE>MAIN_SIDE_A CCESS //对code编码需要特殊处理 存在多个属性值时渲染优先级SA>PA,存在多个属性值时渲染优先级FRONTAGE>MAIN_SIDE_A CCESS
@ -697,6 +702,7 @@ class ImportOMDBHelper @AssistedInject constructor(
renderEntity.propertiesDb = DeflaterUtil.zipString(JSON.toJSONString(renderEntity.properties)) renderEntity.propertiesDb = DeflaterUtil.zipString(JSON.toJSONString(renderEntity.properties))
listRenderEntity.add(renderEntity) listRenderEntity.add(renderEntity)
} }
if (listRenderEntity.size > 20000) { if (listRenderEntity.size > 20000) {

View File

@ -242,8 +242,9 @@ class ImportPreProcess {
startEndReference.properties["type"] = "s_2_e" startEndReference.properties["type"] = "s_2_e"
val listResult = mutableListOf<ReferenceEntity>() val listResult = mutableListOf<ReferenceEntity>()
startEndReference.propertiesDb = DeflaterUtil.zipString(JSON.toJSONString(startEndReference.properties)) startEndReference.propertiesDb = DeflaterUtil.zipString(JSON.toJSONString(startEndReference.properties))
listResult.add(startEndReference) renderEntity.referenceEntitys?.add(startEndReference)
insertData(listResult) //listResult.add(startEndReference)
//insertData(listResult)
} }
/** /**
@ -292,9 +293,9 @@ class ImportPreProcess {
endReference.properties["qi_table"] = renderEntity.table endReference.properties["qi_table"] = renderEntity.table
endReference.properties["type"] = "e_2_p" endReference.properties["type"] = "e_2_p"
endReference.properties["geometry"] = endReference.geometry endReference.properties["geometry"] = endReference.geometry
renderEntity.referenceEntitys?.add(endReference)
listResult.add(endReference) //listResult.add(endReference)
insertData(listResult) //insertData(listResult)
} }
} }
@ -379,9 +380,10 @@ class ImportPreProcess {
} }
endReference.properties["geometry"] = endReference.geometry endReference.properties["geometry"] = endReference.geometry
endReference.propertiesDb = DeflaterUtil.zipString(JSON.toJSONString(endReference.properties)) endReference.propertiesDb = DeflaterUtil.zipString(JSON.toJSONString(endReference.properties))
listResult.add(endReference) renderEntity.referenceEntitys?.add(endReference)
//listResult.add(endReference)
Log.e("qj", "generateS2EReferencePoint===4") Log.e("qj", "generateS2EReferencePoint===4")
insertData(listResult) //insertData(listResult)
} }
/** /**
@ -477,9 +479,10 @@ class ImportPreProcess {
angleReference.properties["qi_table"] = renderEntity.table angleReference.properties["qi_table"] = renderEntity.table
angleReference.properties["type"] = "angle" angleReference.properties["type"] = "angle"
angleReference.propertiesDb = DeflaterUtil.zipString(JSON.toJSONString(angleReference.properties)) angleReference.propertiesDb = DeflaterUtil.zipString(JSON.toJSONString(angleReference.properties))
listResult.add(angleReference) renderEntity.referenceEntitys?.add(angleReference)
//listResult.add(angleReference)
} }
insertData(listResult) //insertData(listResult)
} }
fun addAngleFromGeometry(renderEntity: RenderEntity): String { fun addAngleFromGeometry(renderEntity: RenderEntity): String {
@ -634,9 +637,10 @@ class ImportPreProcess {
"assets:omdb/4601/${type}/1301_${referenceEntity.properties["currentDirect"]}.svg" "assets:omdb/4601/${type}/1301_${referenceEntity.properties["currentDirect"]}.svg"
Log.d("unpackingLaneInfo", referenceEntity.properties["symbol"].toString()) Log.d("unpackingLaneInfo", referenceEntity.properties["symbol"].toString())
referenceEntity.propertiesDb = DeflaterUtil.zipString(JSON.toJSONString(referenceEntity.properties)) referenceEntity.propertiesDb = DeflaterUtil.zipString(JSON.toJSONString(referenceEntity.properties))
listResult.add(referenceEntity) renderEntity.referenceEntitys?.add(referenceEntity)
//listResult.add(referenceEntity)
} }
insertData(listResult) //insertData(listResult)
} }
} }
} }
@ -744,8 +748,9 @@ class ImportPreProcess {
angleReference.enable = renderEntity.enable angleReference.enable = renderEntity.enable
val listResult = mutableListOf<ReferenceEntity>() val listResult = mutableListOf<ReferenceEntity>()
angleReference.propertiesDb = DeflaterUtil.zipString(JSON.toJSONString(angleReference.properties)) angleReference.propertiesDb = DeflaterUtil.zipString(JSON.toJSONString(angleReference.properties))
listResult.add(angleReference) renderEntity.referenceEntitys?.add(angleReference)
insertData(listResult) //listResult.add(angleReference)
//insertData(listResult)
} }
@ -775,9 +780,10 @@ class ImportPreProcess {
intersectionReference.properties["qi_table"] = renderEntity.table intersectionReference.properties["qi_table"] = renderEntity.table
intersectionReference.properties["type"] = "node" intersectionReference.properties["type"] = "node"
intersectionReference.propertiesDb = DeflaterUtil.zipString(JSON.toJSONString(intersectionReference.properties)) intersectionReference.propertiesDb = DeflaterUtil.zipString(JSON.toJSONString(intersectionReference.properties))
listResult.add(intersectionReference) renderEntity.referenceEntitys?.add(intersectionReference)
//listResult.add(intersectionReference)
} }
insertData(listResult) //insertData(listResult)
} }
} }
@ -944,9 +950,10 @@ class ImportPreProcess {
val code = renderEntity.properties[codeName] val code = renderEntity.properties[codeName]
dynamicSrcReference.properties["src"] = "${prefix}${code}${suffix}" dynamicSrcReference.properties["src"] = "${prefix}${code}${suffix}"
dynamicSrcReference.propertiesDb = DeflaterUtil.zipString(JSON.toJSONString(dynamicSrcReference.properties)) dynamicSrcReference.propertiesDb = DeflaterUtil.zipString(JSON.toJSONString(dynamicSrcReference.properties))
listResult.add(dynamicSrcReference) renderEntity.referenceEntitys?.add(dynamicSrcReference)
//listResult.add(dynamicSrcReference)
} }
insertData(listResult) //insertData(listResult)
} }
private fun insertData(list: List<RealmModel>) { private fun insertData(list: List<RealmModel>) {

View File

@ -854,7 +854,7 @@ class MainViewModel @Inject constructor(
*/ */
private suspend fun captureLink(point: GeoPoint) { private suspend fun captureLink(point: GeoPoint) {
if (captureLinkState) { if (captureLinkState||Constant.INSTALL_DATA) {
return return
} }

View File

@ -108,6 +108,7 @@ open class RenderEntity() : RealmObject(), Parcelable {
@Index @Index
var linkPid: String = "" // RenderEntity关联的linkPid集合(可能会关联多个) var linkPid: String = "" // RenderEntity关联的linkPid集合(可能会关联多个)
var linkRelation: LinkRelation? = null var linkRelation: LinkRelation? = null
var referenceEntitys: RealmSet<ReferenceEntity>? = RealmSet()//
constructor(name: String) : this() { constructor(name: String) : this() {
this.name = name this.name = name

View File

@ -4,10 +4,13 @@ import static org.oscim.core.MercatorProjection.latitudeToY;
import static org.oscim.core.MercatorProjection.longitudeToX; import static org.oscim.core.MercatorProjection.longitudeToX;
import android.os.Build; import android.os.Build;
import android.util.Log;
import androidx.annotation.RequiresApi; 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.enums.DataCodeEnum;
import com.navinfo.collect.library.utils.GeometryTools;
import org.locationtech.jts.geom.Coordinate; import org.locationtech.jts.geom.Coordinate;
import org.locationtech.jts.geom.Geometry; import org.locationtech.jts.geom.Geometry;
@ -103,7 +106,14 @@ public class OMDBDataDecoder extends TileDecoder {
processCoordinateArray(multiPoint.getGeometryN(i).getCoordinates(), false); processCoordinateArray(multiPoint.getGeometryN(i).getCoordinates(), false);
} }
} else if (geometry instanceof LineString) { } else if (geometry instanceof LineString) {
processLineString((LineString) geometry); //将车道中心进行转化面渲染
if(layerName!=null&&layerName.equals(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) { } else if (geometry instanceof MultiLineString) {
MultiLineString multiLineString = (MultiLineString) geometry; MultiLineString multiLineString = (MultiLineString) geometry;
for (int i = 0; i < multiLineString.getNumGeometries(); i++) { for (int i = 0; i < multiLineString.getNumGeometries(); i++) {

View File

@ -71,25 +71,35 @@ public class DeflaterUtil{
deflater.finish(); deflater.finish();
final byte[] bytes = new byte[256]; final byte[] bytes = new byte[512];
ByteArrayOutputStream outputStream = new ByteArrayOutputStream(256); ByteArrayOutputStream outputStream = new ByteArrayOutputStream(512);
while (!deflater.finished()) { try {
//压缩输入数据并用压缩数据填充指定的缓冲区 while (!deflater.finished()) {
int length = deflater.deflate(bytes); //压缩输入数据并用压缩数据填充指定的缓冲区
outputStream.write(bytes, 0, length); int length = deflater.deflate(bytes);
outputStream.write(bytes, 0, length);
}
deflater.end();
return Base64.encodeBase64String(outputStream.toByteArray());
}catch (Exception e){
return null;
}finally {
try {
outputStream.close();
}catch (Exception e){
}
} }
deflater.end();
return Base64.encodeBase64String(outputStream.toByteArray());
} }
/** /**
@ -108,9 +118,9 @@ public class DeflaterUtil{
inflater.setInput(decode); inflater.setInput(decode);
final byte[] bytes = new byte[256]; final byte[] bytes = new byte[512];
ByteArrayOutputStream outputStream = new ByteArrayOutputStream(256); ByteArrayOutputStream outputStream = new ByteArrayOutputStream(512);
try { try {
@ -150,6 +160,12 @@ public class DeflaterUtil{
return null; return null;
}finally {
try {
outputStream.close();
}catch (Exception e){
}
} }
} }