Merge branch 'master' of gitlab.navinfo.com:CollectVehicle/OneMapQS
Conflicts: vtm
This commit is contained in:
commit
c6bf940dc4
@ -20,6 +20,19 @@
|
||||
"code": 2010,
|
||||
"name": "道路方向"
|
||||
},
|
||||
"2013": {
|
||||
"table": "OMDB_LANE_MARK_BOUNDARYTYPE",
|
||||
"code": 2013,
|
||||
"name": "车道边界类型",
|
||||
"transformer": [
|
||||
{
|
||||
"k": "geometry",
|
||||
"v": "~",
|
||||
"klib": "geometry",
|
||||
"vlib": "unpackingLaneBoundary()"
|
||||
}
|
||||
]
|
||||
},
|
||||
"2019": {
|
||||
"table": "OMDB_LINK_SPEEDLIMIT",
|
||||
"code": 2019,
|
||||
@ -55,6 +68,11 @@
|
||||
"code": 2041,
|
||||
"name": "车道数"
|
||||
},
|
||||
"2083":{
|
||||
"table": "OMDB_RDBOUND_BOUNDARYTYPE",
|
||||
"code": 2083,
|
||||
"name": "道路边界类型"
|
||||
},
|
||||
"2201":{
|
||||
"table": "OMDB_BRIDGE",
|
||||
"code": 2201,
|
||||
@ -131,7 +149,7 @@
|
||||
"k": "geometry",
|
||||
"v": "~",
|
||||
"klib": "geometry",
|
||||
"vlib": "translateRightWithAngle()"
|
||||
"vlib": "generateRestrictionRerference()"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -1,7 +1,11 @@
|
||||
package com.navinfo.omqs.db
|
||||
|
||||
import com.navinfo.collect.library.data.entity.ReferenceEntity
|
||||
import com.navinfo.collect.library.data.entity.RenderEntity
|
||||
import com.navinfo.collect.library.utils.GeometryTools
|
||||
import io.realm.Realm
|
||||
import org.json.JSONArray
|
||||
import org.json.JSONObject
|
||||
import org.locationtech.jts.algorithm.Angle
|
||||
import org.locationtech.jts.geom.Coordinate
|
||||
import org.locationtech.jts.geom.Geometry
|
||||
@ -60,7 +64,9 @@ class ImportPreProcess {
|
||||
var radian = 0.0 // geometry的角度,如果是点,获取angle,如果是线,获取最后两个点的方向
|
||||
var point = Coordinate(geometry?.coordinate)
|
||||
if (Geometry.TYPENAME_POINT == geometry?.geometryType) {
|
||||
val angle = if(renderEntity?.properties?.get("angle") == null) 0.0 else renderEntity?.properties?.get("angle")?.toDouble()!!
|
||||
// angle为正北方向夹角,需要将其转换为与正东方向夹角
|
||||
var angle = if(renderEntity?.properties?.get("angle") == null) 0.0 else renderEntity?.properties?.get("angle")?.toDouble()!!
|
||||
angle-=90
|
||||
radian = Math.toRadians(angle)
|
||||
} else if (Geometry.TYPENAME_LINESTRING == geometry?.geometryType) {
|
||||
val p1: Coordinate = geometry.coordinates.get(geometry.coordinates.size - 2)
|
||||
@ -77,6 +83,7 @@ class ImportPreProcess {
|
||||
// 计算偏移后的点
|
||||
// val coordMid =
|
||||
// Coordinate(point.getX() + dy, point.getY() - dx)
|
||||
// 计算指定距离外与当前位置成90度夹角的点位
|
||||
val pointStart = GeoPoint(point.getY() - dx, point.getX() + dy)
|
||||
// val pointStart = GeoPoint(pointMid.latitude-dy, pointMid.longitude-dx)
|
||||
val pointEnd = GeoPoint(pointStart.latitude- dx, pointStart.longitude+ dy)
|
||||
@ -107,4 +114,66 @@ class ImportPreProcess {
|
||||
}
|
||||
return "0"
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析车道边线数据二级属性
|
||||
* */
|
||||
fun unpackingLaneBoundary(renderEntity: RenderEntity) {
|
||||
if (renderEntity.code == 2013&&!renderEntity.properties["shapeList"].isNullOrEmpty()&&renderEntity.properties["shapeList"]!="null") {
|
||||
// 解析shapeList,将数组中的属性放会properties
|
||||
val shapeList = JSONArray(renderEntity.properties["shapeList"])
|
||||
val shape = shapeList.getJSONObject(0)
|
||||
for (key in shape.keys()) {
|
||||
renderEntity.properties[key] = shape[key].toString()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 自动生成普通交限的参考数据
|
||||
* */
|
||||
fun generateRestrictionRerference(renderEntity: RenderEntity) {
|
||||
// 获取当前renderEntity的geometry
|
||||
val geometry = renderEntity.wkt
|
||||
var radian = 0.0 // geometry的角度,如果是点,获取angle,如果是线,获取最后两个点的方向
|
||||
var point = Coordinate(geometry?.coordinate)
|
||||
if (Geometry.TYPENAME_POINT == geometry?.geometryType) {
|
||||
var angle = if(renderEntity?.properties?.get("angle") == null) 0.0 else renderEntity?.properties?.get("angle")?.toDouble()!!
|
||||
radian = Math.toRadians(angle)
|
||||
}
|
||||
|
||||
// 计算偏移距离
|
||||
val dx: Double = GeometryTools.convertDistanceToDegree(3.0, geometry?.coordinate?.y!!) * Math.sin(radian)
|
||||
val dy: Double = GeometryTools.convertDistanceToDegree(3.0, geometry?.coordinate?.y!!) * Math.cos(radian)
|
||||
|
||||
// 计算偏移后的点
|
||||
val pointTranS =
|
||||
GeoPoint(point.getY() - dx, point.getX() + dy) // 向右偏移的点
|
||||
|
||||
// 计算与原有方向平行的终点坐标
|
||||
val pointTranE = GeoPoint(pointTranS.latitude + dy, pointTranS.longitude + dx)
|
||||
|
||||
renderEntity.geometry = GeometryTools.createGeometry(pointTranS).toString()
|
||||
|
||||
// 将这个点记录在数据中
|
||||
val startEndReference = ReferenceEntity()
|
||||
startEndReference.renderEntityId = renderEntity.id
|
||||
startEndReference.name = "普通交限参考线"
|
||||
startEndReference.table = renderEntity.table
|
||||
// 起终点坐标组成的线
|
||||
startEndReference.geometry = GeometryTools.createLineString(listOf(GeoPoint(point.y, point.x), pointTranS)).toString()
|
||||
startEndReference.properties["qi_table"] = renderEntity.table
|
||||
startEndReference.properties["type"] = "s_2_e"
|
||||
Realm.getDefaultInstance().insert(startEndReference)
|
||||
|
||||
val angleReference = ReferenceEntity()
|
||||
angleReference.renderEntityId = renderEntity.id
|
||||
angleReference.name = "普通交限参考方向"
|
||||
angleReference.table = renderEntity.table
|
||||
// 与原有方向指向平行的线
|
||||
angleReference.geometry = GeometryTools.createLineString(listOf(pointTranS, pointTranE)).toString()
|
||||
angleReference.properties["qi_table"] = renderEntity.table
|
||||
angleReference.properties["type"] = "angle"
|
||||
Realm.getDefaultInstance().insert(angleReference)
|
||||
}
|
||||
}
|
@ -228,7 +228,7 @@ class LoginViewModel @Inject constructor(
|
||||
.name("OMQS.realm")
|
||||
.encryptionKey(password)
|
||||
// .modules(Realm.getDefaultModule(), MyRealmModule())
|
||||
.schemaVersion(1)
|
||||
.schemaVersion(2)
|
||||
.build()
|
||||
Realm.setDefaultConfiguration(config)
|
||||
// 拷贝配置文件到用户目录下
|
||||
|
@ -111,7 +111,7 @@ class PersonalCenterFragment : BaseFragment(), FSAFActivityCallbacks {
|
||||
viewModel.readRealmData()
|
||||
// 定位到指定位置
|
||||
niMapController.mMapView.vtmMap.animator()
|
||||
.animateTo(GeoPoint(28.724637921467508 ,115.83412668023867 ))
|
||||
.animateTo(GeoPoint(40.031657799200346, 116.32207834810715 ))
|
||||
}
|
||||
R.id.personal_center_menu_task_list -> {
|
||||
findNavController().navigate(R.id.TaskManagerFragment)
|
||||
|
@ -173,6 +173,9 @@
|
||||
<!-- oneway -->
|
||||
<style-symbol id="oneway" repeat="true" src="assets:symbols/oneway.svg" />
|
||||
|
||||
<!-- omdb -->
|
||||
<style-line id="boundaryType" width="0.1" stipple-width="0.1" />
|
||||
|
||||
<!--###### ASSIGNMENT ######-->
|
||||
|
||||
<m e="way" k="natural" v="issea|sea">
|
||||
@ -1651,81 +1654,6 @@
|
||||
<caption k="maxSpeed" fill="#000000" priority="0" size="16" stroke="#ffffff"
|
||||
stroke-width="1.0"></caption>
|
||||
<symbol src="assets:omdb/icon_4002_0.png" symbol-width="46" symbol-height="46"></symbol>
|
||||
<!-- <circle fill="#ffffff" radius="28" scale-radius="true" stroke="#ff0000" stroke-width="6"/>-->
|
||||
<!-- <m k="maxSpeed">-->
|
||||
<!-- <m v="5">-->
|
||||
<!-- <symbol src="assets:omdb/1101/1101_5_0.png"></symbol>-->
|
||||
<!-- </m>-->
|
||||
<!-- <m v="10">-->
|
||||
<!-- <symbol src="assets:omdb/1101/1101_10_0.png"></symbol>-->
|
||||
<!-- </m>-->
|
||||
<!-- <m v="15">-->
|
||||
<!-- <symbol src="assets:omdb/1101/1101_15_0.png"></symbol>-->
|
||||
<!-- </m>-->
|
||||
<!-- <m v="20">-->
|
||||
<!-- <symbol src="assets:omdb/1101/1101_20_0.png"></symbol>-->
|
||||
<!-- </m>-->
|
||||
<!-- <m v="25">-->
|
||||
<!-- <symbol src="assets:omdb/1101/1101_25_0.png"></symbol>-->
|
||||
<!-- </m>-->
|
||||
<!-- <m v="30">-->
|
||||
<!-- <symbol src="assets:omdb/1101/1101_30_0.png"></symbol>-->
|
||||
<!-- </m>-->
|
||||
<!-- <m v="35">-->
|
||||
<!-- <symbol src="assets:omdb/1101/1101_35_0.png"></symbol>-->
|
||||
<!-- </m>-->
|
||||
<!-- <m v="40">-->
|
||||
<!-- <symbol src="assets:omdb/1101/1101_40_0.png"></symbol>-->
|
||||
<!-- </m>-->
|
||||
<!-- <m v="45">-->
|
||||
<!-- <symbol src="assets:omdb/1101/1101_45_0.png"></symbol>-->
|
||||
<!-- </m>-->
|
||||
<!-- <m v="50">-->
|
||||
<!-- <symbol src="assets:omdb/1101/1101_50_0.png"></symbol>-->
|
||||
<!-- </m>-->
|
||||
<!-- <m v="55">-->
|
||||
<!-- <symbol src="assets:omdb/1101/1101_55_0.png"></symbol>-->
|
||||
<!-- </m>-->
|
||||
<!-- <m v="60">-->
|
||||
<!-- <symbol src="assets:omdb/1101/1101_60_0.png"></symbol>-->
|
||||
<!-- </m>-->
|
||||
<!-- <m v="65">-->
|
||||
<!-- <symbol src="assets:omdb/1101/1101_65_0.png"></symbol>-->
|
||||
<!-- </m>-->
|
||||
<!-- <m v="70">-->
|
||||
<!-- <symbol src="assets:omdb/1101/1101_70_0.png"></symbol>-->
|
||||
<!-- </m>-->
|
||||
<!-- <m v="75">-->
|
||||
<!-- <symbol src="assets:omdb/1101/1101_75_0.png"></symbol>-->
|
||||
<!-- </m>-->
|
||||
<!-- <m v="80">-->
|
||||
<!-- <symbol src="assets:omdb/1101/1101_80_0.png"></symbol>-->
|
||||
<!-- </m>-->
|
||||
<!-- <m v="85">-->
|
||||
<!-- <symbol src="assets:omdb/1101/1101_85_0.png"></symbol>-->
|
||||
<!-- </m>-->
|
||||
<!-- <m v="90">-->
|
||||
<!-- <symbol src="assets:omdb/1101/1101_90_0.png"></symbol>-->
|
||||
<!-- </m>-->
|
||||
<!-- <m v="95">-->
|
||||
<!-- <symbol src="assets:omdb/1101/1101_95_0.png"></symbol>-->
|
||||
<!-- </m>-->
|
||||
<!-- <m v="100">-->
|
||||
<!-- <symbol src="assets:omdb/1101/1101_100_0.png"></symbol>-->
|
||||
<!-- </m>-->
|
||||
<!-- <m v="105">-->
|
||||
<!-- <symbol src="assets:omdb/1101/1101_105_0.png"></symbol>-->
|
||||
<!-- </m>-->
|
||||
<!-- <m v="110">-->
|
||||
<!-- <symbol src="assets:omdb/1101/1101_110_0.png"></symbol>-->
|
||||
<!-- </m>-->
|
||||
<!-- <m v="115">-->
|
||||
<!-- <symbol src="assets:omdb/1101/1101_115_0.png"></symbol>-->
|
||||
<!-- </m>-->
|
||||
<!-- <m v="120">-->
|
||||
<!-- <symbol src="assets:omdb/1101/1101_120_0.png"></symbol>-->
|
||||
<!-- </m>-->
|
||||
<!-- </m>-->
|
||||
<caption k="minSpeed" dy="-28" fill="#000000" priority="0" size="14" stroke="#ffffff"
|
||||
stroke-width="1.0"></caption>
|
||||
</m>
|
||||
@ -1733,81 +1661,6 @@
|
||||
<caption k="maxSpeed" fill="#000000" priority="0" size="14" stroke="#ffffff"
|
||||
stroke-width="1.0"></caption>
|
||||
<symbol src="assets:omdb/icon_4002_1.png" symbol-width="46" symbol-height="46"></symbol>
|
||||
<!-- <circle fill="#ffffff" radius="28" scale-radius="true" stroke="#00ff00" stroke-width="6"/>-->
|
||||
<!-- <m k="maxSpeed">-->
|
||||
<!-- <m v="5">-->
|
||||
<!-- <symbol src="assets:omdb/1101/1101_5_1.png"></symbol>-->
|
||||
<!-- </m>-->
|
||||
<!-- <m v="10">-->
|
||||
<!-- <symbol src="assets:omdb/1101/1101_10_1.png"></symbol>-->
|
||||
<!-- </m>-->
|
||||
<!-- <m v="15">-->
|
||||
<!-- <symbol src="assets:omdb/1101/1101_15_1.png"></symbol>-->
|
||||
<!-- </m>-->
|
||||
<!-- <m v="20">-->
|
||||
<!-- <symbol src="assets:omdb/1101/1101_20_1.png"></symbol>-->
|
||||
<!-- </m>-->
|
||||
<!-- <m v="25">-->
|
||||
<!-- <symbol src="assets:omdb/1101/1101_25_1.png"></symbol>-->
|
||||
<!-- </m>-->
|
||||
<!-- <m v="30">-->
|
||||
<!-- <symbol src="assets:omdb/1101/1101_30_1.png"></symbol>-->
|
||||
<!-- </m>-->
|
||||
<!-- <m v="35">-->
|
||||
<!-- <symbol src="assets:omdb/1101/1101_35_1.png"></symbol>-->
|
||||
<!-- </m>-->
|
||||
<!-- <m v="40">-->
|
||||
<!-- <symbol src="assets:omdb/1101/1101_40_1.png"></symbol>-->
|
||||
<!-- </m>-->
|
||||
<!-- <m v="45">-->
|
||||
<!-- <symbol src="assets:omdb/1101/1101_45_1.png"></symbol>-->
|
||||
<!-- </m>-->
|
||||
<!-- <m v="50">-->
|
||||
<!-- <symbol src="assets:omdb/1101/1101_50_1.png"></symbol>-->
|
||||
<!-- </m>-->
|
||||
<!-- <m v="55">-->
|
||||
<!-- <symbol src="assets:omdb/1101/1101_55_1.png"></symbol>-->
|
||||
<!-- </m>-->
|
||||
<!-- <m v="60">-->
|
||||
<!-- <symbol src="assets:omdb/1101/1101_60_1.png"></symbol>-->
|
||||
<!-- </m>-->
|
||||
<!-- <m v="65">-->
|
||||
<!-- <symbol src="assets:omdb/1101/1101_65_1.png"></symbol>-->
|
||||
<!-- </m>-->
|
||||
<!-- <m v="70">-->
|
||||
<!-- <symbol src="assets:omdb/1101/1101_70_1.png"></symbol>-->
|
||||
<!-- </m>-->
|
||||
<!-- <m v="75">-->
|
||||
<!-- <symbol src="assets:omdb/1101/1101_75_1.png"></symbol>-->
|
||||
<!-- </m>-->
|
||||
<!-- <m v="80">-->
|
||||
<!-- <symbol src="assets:omdb/1101/1101_80_1.png"></symbol>-->
|
||||
<!-- </m>-->
|
||||
<!-- <m v="85">-->
|
||||
<!-- <symbol src="assets:omdb/1101/1101_85_1.png"></symbol>-->
|
||||
<!-- </m>-->
|
||||
<!-- <m v="90">-->
|
||||
<!-- <symbol src="assets:omdb/1101/1101_90_1.png"></symbol>-->
|
||||
<!-- </m>-->
|
||||
<!-- <m v="95">-->
|
||||
<!-- <symbol src="assets:omdb/1101/1101_95_1.png"></symbol>-->
|
||||
<!-- </m>-->
|
||||
<!-- <m v="100">-->
|
||||
<!-- <symbol src="assets:omdb/1101/1101_100_1.png"></symbol>-->
|
||||
<!-- </m>-->
|
||||
<!-- <m v="105">-->
|
||||
<!-- <symbol src="assets:omdb/1101/1101_105_1.png"></symbol>-->
|
||||
<!-- </m>-->
|
||||
<!-- <m v="110">-->
|
||||
<!-- <symbol src="assets:omdb/1101/1101_110_1.png"></symbol>-->
|
||||
<!-- </m>-->
|
||||
<!-- <m v="115">-->
|
||||
<!-- <symbol src="assets:omdb/1101/1101_115_1.png"></symbol>-->
|
||||
<!-- </m>-->
|
||||
<!-- <m v="120">-->
|
||||
<!-- <symbol src="assets:omdb/1101/1101_120_1.png"></symbol>-->
|
||||
<!-- </m>-->
|
||||
<!-- </m>-->
|
||||
<caption k="minSpeed" dy="-28" fill="#000000" priority="0" size="14" stroke="#ffffff"
|
||||
stroke-width="1.0"></caption>
|
||||
</m>
|
||||
@ -1855,6 +1708,70 @@
|
||||
<m v="OMDB_LANE_LINK_LG">
|
||||
<line stroke="#ecf0f1" width="0.1" dasharray="35,35"/>
|
||||
</m>
|
||||
<!-- 道路边界类型 -->
|
||||
<m v="OMDB_RDBOUND_BOUNDARYTYPE">
|
||||
<line stroke="#ffffff" width="0.1"/>
|
||||
</m>
|
||||
<!-- 车道边界类型 -->
|
||||
<m v="OMDB_LANE_MARK_BOUNDARYTYPE">
|
||||
<outline-layer id="boundary" stroke="#ffffff" width="0.2" />
|
||||
<m k="boundaryType">
|
||||
<!--标线-->
|
||||
<m v="2">
|
||||
<m k="markType">
|
||||
<!--其他|实线-->
|
||||
<m v="0|1">
|
||||
<m k="markColor">
|
||||
<m v="0|1">
|
||||
<line stroke="#ffffff" use="boundaryType"/>
|
||||
</m>
|
||||
<m v="2">
|
||||
<line stroke="#eccc68" use="boundaryType"/>
|
||||
</m>
|
||||
<m v="6">
|
||||
<line stroke="#0000ff" use="boundaryType"/>
|
||||
</m>
|
||||
<m v="7">
|
||||
<line stroke="#00ff00" use="boundaryType"/>
|
||||
</m>
|
||||
<m v="9">
|
||||
<line stroke="#8e44ad" use="boundaryType"/>
|
||||
</m>
|
||||
</m>
|
||||
</m>
|
||||
<!--虚线-->
|
||||
<m v="2">
|
||||
<m k="markColor">
|
||||
<m v="0|1">
|
||||
<line stroke="#ffffff" use="boundaryType" dasharray="3,13"/>
|
||||
</m>
|
||||
<m v="2">
|
||||
<line stroke="#eccc68" use="boundaryType" dasharray="3,3"/>
|
||||
</m>
|
||||
<m v="6">
|
||||
<line stroke="#0000ff" use="boundaryType" dasharray="3,3"/>
|
||||
</m>
|
||||
<m v="7">
|
||||
<line stroke="#00ff00" use="boundaryType" dasharray="3,3"/>
|
||||
</m>
|
||||
<m v="9">
|
||||
<line stroke="#8e44ad" use="boundaryType" dasharray="3,3"/>
|
||||
</m>
|
||||
</m>
|
||||
</m>
|
||||
<!--导流区边线-->
|
||||
<m v="4">
|
||||
<line outline="boundary" stroke="#545D6C"></line>
|
||||
<lineSymbol src="assets:omdb/icon_right.png" repeat-start="0" repeat-gap="0.5"/>
|
||||
</m>
|
||||
<!-- <!–铺设路面边缘–>-->
|
||||
<!-- <m v="5">-->
|
||||
<!-- <line outline="#ffffff" fix="true" src="assets:omdb/icon_close.png" stroke="#ffffffff" use="boundaryType"/>-->
|
||||
<!-- </m>-->
|
||||
</m>
|
||||
</m>
|
||||
</m>
|
||||
</m>
|
||||
<!--道路方向-->
|
||||
<m v="OMDB_LINK_DIRECT">
|
||||
<m k="direct">
|
||||
@ -1874,11 +1791,15 @@
|
||||
</m>
|
||||
<!--普通交限-->
|
||||
<m v="OMDB_RESTRICTION">
|
||||
<symbol src="assets:omdb/icon_4006_0.png" repeat="false" symbol-width="35" symbol-height="35" rotate="true" repeat-start="0" ></symbol>
|
||||
<!-- <line stroke="#14582c" width="0.1"/>-->
|
||||
<!-- <caption k="angle" fill="#000000" priority="0" size="14" stroke="#ffffff"-->
|
||||
<!-- stroke-width="1.0"></caption>-->
|
||||
|
||||
<m k="angle">
|
||||
<symbol src="assets:omdb/icon_4006_0.png" repeat="false" symbol-width="35" symbol-height="35" rotate="false" repeat-start="0" ></symbol>
|
||||
</m>
|
||||
<m k="type" v="angle">
|
||||
<symbol src="assets:omdb/icon_arrow_right.png" repeat-start="0" repeat-gap="2000" symbol-percent="45" repeat="false" rotate="true"></symbol>
|
||||
</m>
|
||||
<m k="type" v="s_2_e">
|
||||
<line stroke="#14582c" width="0.1" dasharray="1,1" repeat-gap="3" repeat-start="0"/>
|
||||
</m>
|
||||
</m>
|
||||
</m>
|
||||
</rendertheme>
|
BIN
collect-library/src/main/assets/omdb/icon_arrow_right.png
Normal file
BIN
collect-library/src/main/assets/omdb/icon_arrow_right.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.0 KiB |
BIN
collect-library/src/main/assets/omdb/icon_close.png
Normal file
BIN
collect-library/src/main/assets/omdb/icon_close.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 279 B |
BIN
collect-library/src/main/assets/omdb/icon_right.png
Normal file
BIN
collect-library/src/main/assets/omdb/icon_right.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 305 B |
@ -0,0 +1,64 @@
|
||||
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
|
||||
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.*
|
||||
|
||||
/**
|
||||
* 渲染要素对应的实体
|
||||
* */
|
||||
open class ReferenceEntity() : RealmObject() {
|
||||
@PrimaryKey
|
||||
var id: String = UUID.randomUUID().toString() // id
|
||||
var renderEntityId: String = "" // 参考的renderEntity的Id
|
||||
lateinit var name: String //要素名
|
||||
lateinit var table: String //要素表名
|
||||
var code: Int = 0 // 要素编码
|
||||
var geometry: String = "" // 要素渲染参考的geometry,该数据可能会在导入预处理环节被修改,原始geometry会保存在properties的geometry字段下
|
||||
get() {
|
||||
wkt = GeometryTools.createGeometry(field)
|
||||
return field
|
||||
}
|
||||
set(value) {
|
||||
field = value
|
||||
// 根据geometry自动计算当前要素的x-tile和y-tile
|
||||
GeometryToolsKt.getTileXByGeometry(value, tileX)
|
||||
GeometryToolsKt.getTileYByGeometry(value, tileY)
|
||||
// 根据传入的geometry文本,自动转换为Geometry对象
|
||||
try {
|
||||
wkt = GeometryTools.createGeometry(value)
|
||||
} catch (e: Exception) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Ignore
|
||||
var wkt: Geometry? = null
|
||||
get() {
|
||||
if (field == null || field!!.isEmpty) {
|
||||
try {
|
||||
field = GeometryTools.createGeometry(geometry)
|
||||
} catch (e: Exception) {
|
||||
|
||||
}
|
||||
}
|
||||
return field
|
||||
}
|
||||
var properties: RealmDictionary<String> = RealmDictionary()
|
||||
var tileX: RealmSet<Int> = RealmSet() // x方向的tile编码
|
||||
var tileY: RealmSet<Int> = RealmSet() // y方向的tile编码
|
||||
|
||||
constructor(name: String): this() {
|
||||
this.name = name
|
||||
}
|
||||
|
||||
}
|
@ -4,6 +4,7 @@ import androidx.appcompat.app.AppCompatActivity
|
||||
import com.navinfo.collect.library.map.NIMapView
|
||||
import com.navinfo.collect.library.map.source.MapLifeNiLocationTileSource
|
||||
import com.navinfo.collect.library.map.source.NavinfoMultiMapFileTileSource
|
||||
import com.navinfo.collect.library.map.source.OMDBReferenceTileSource
|
||||
import com.navinfo.collect.library.map.source.OMDBTileSource
|
||||
import com.navinfo.collect.library.system.Constant
|
||||
import okhttp3.Cache
|
||||
@ -45,9 +46,12 @@ class LayerManagerHandler(context: AppCompatActivity, mapView: NIMapView,tracePa
|
||||
* 显示待测评OMDB数据的图层
|
||||
* */
|
||||
private lateinit var omdbVectorTileLayer: VectorTileLayer
|
||||
private lateinit var omdbReferenceTileLayer: VectorTileLayer
|
||||
private lateinit var omdbLabelLayer: LabelLayer
|
||||
private lateinit var omdbReferenceLabelLayer: LabelLayer
|
||||
|
||||
private val omdbTileSource by lazy { OMDBTileSource() }
|
||||
private val omdbReferenceTileSource by lazy { OMDBReferenceTileSource() }
|
||||
|
||||
init {
|
||||
initMap()
|
||||
@ -99,6 +103,7 @@ class LayerManagerHandler(context: AppCompatActivity, mapView: NIMapView,tracePa
|
||||
}
|
||||
|
||||
private fun initOMDBVectorTileLayer() {
|
||||
// 初始化OMDB相关图层
|
||||
omdbVectorTileLayer = VectorTileLayer(mMapView.vtmMap, omdbTileSource)
|
||||
omdbLabelLayer = LabelLayer(mMapView.vtmMap, omdbVectorTileLayer, LabelTileLoaderHook(), Constant.OMDB_MIN_ZOOM)
|
||||
if(omdbVectorTileLayer!=null){
|
||||
@ -107,6 +112,16 @@ class LayerManagerHandler(context: AppCompatActivity, mapView: NIMapView,tracePa
|
||||
if(omdbLabelLayer!=null){
|
||||
addLayer(omdbLabelLayer, NIMapView.LAYER_GROUPS.VECTOR_TILE)
|
||||
}
|
||||
|
||||
// 初始化OMDB参考相关图层
|
||||
omdbReferenceTileLayer = VectorTileLayer(mMapView.vtmMap, omdbReferenceTileSource)
|
||||
omdbReferenceLabelLayer = LabelLayer(mMapView.vtmMap, omdbReferenceTileLayer, LabelTileLoaderHook(), Constant.OMDB_MIN_ZOOM)
|
||||
if(omdbReferenceTileLayer!=null){
|
||||
addLayer(omdbReferenceTileLayer,NIMapView.LAYER_GROUPS.VECTOR_TILE)
|
||||
}
|
||||
if(omdbReferenceLabelLayer!=null){
|
||||
addLayer(omdbReferenceLabelLayer, NIMapView.LAYER_GROUPS.VECTOR_TILE)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -0,0 +1,71 @@
|
||||
package com.navinfo.collect.library.map.source;
|
||||
|
||||
import android.os.Build;
|
||||
|
||||
import androidx.annotation.RequiresApi;
|
||||
|
||||
import com.navinfo.collect.library.data.entity.ReferenceEntity;
|
||||
import com.navinfo.collect.library.system.Constant;
|
||||
|
||||
import org.oscim.layers.tile.MapTile;
|
||||
import org.oscim.tiling.ITileDataSink;
|
||||
import org.oscim.tiling.ITileDataSource;
|
||||
import org.oscim.tiling.QueryResult;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.realm.Realm;
|
||||
import io.realm.RealmQuery;
|
||||
|
||||
public class OMDBReferenceDataSource implements ITileDataSource {
|
||||
private final ThreadLocal<OMDBReferenceDecoder> mThreadLocalDecoders = new ThreadLocal<OMDBReferenceDecoder>() {
|
||||
@Override
|
||||
protected OMDBReferenceDecoder initialValue() {
|
||||
return new OMDBReferenceDecoder();
|
||||
}
|
||||
};
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.N)
|
||||
@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);
|
||||
|
||||
RealmQuery<ReferenceEntity> realmQuery = Realm.getDefaultInstance().where(ReferenceEntity.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) {
|
||||
realmQuery.beginGroup();
|
||||
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, mapDataSink, listResult);
|
||||
}
|
||||
mapDataSink.completed(QueryResult.SUCCESS);
|
||||
// Log.d("RealmDBTileDataSource", "tile:"+tile.getBoundingBox().toString());
|
||||
} else {
|
||||
mapDataSink.completed(QueryResult.SUCCESS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancel() {
|
||||
if (Realm.getDefaultInstance().isInTransaction()) {
|
||||
Realm.getDefaultInstance().cancelTransaction();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,186 @@
|
||||
package com.navinfo.collect.library.map.source;
|
||||
|
||||
import static org.oscim.core.MercatorProjection.latitudeToY;
|
||||
import static org.oscim.core.MercatorProjection.longitudeToX;
|
||||
|
||||
import android.os.Build;
|
||||
|
||||
import androidx.annotation.RequiresApi;
|
||||
|
||||
import com.navinfo.collect.library.data.entity.ReferenceEntity;
|
||||
|
||||
import org.locationtech.jts.geom.Coordinate;
|
||||
import org.locationtech.jts.geom.Geometry;
|
||||
import org.locationtech.jts.geom.GeometryFactory;
|
||||
import org.locationtech.jts.geom.LineString;
|
||||
import org.locationtech.jts.geom.MultiLineString;
|
||||
import org.locationtech.jts.geom.MultiPoint;
|
||||
import org.locationtech.jts.geom.MultiPolygon;
|
||||
import org.locationtech.jts.geom.Point;
|
||||
import org.locationtech.jts.geom.Polygon;
|
||||
import org.oscim.core.MapElement;
|
||||
import org.oscim.core.Tag;
|
||||
import org.oscim.core.Tile;
|
||||
import org.oscim.tiling.ITileDataSink;
|
||||
import org.oscim.tiling.source.mvt.TileDecoder;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class OMDBReferenceDecoder extends TileDecoder {
|
||||
private final String mLocale;
|
||||
|
||||
private static final float REF_TILE_SIZE = 4096.0f;
|
||||
|
||||
private final GeometryFactory mGeomFactory;
|
||||
private final MapElement mMapElement;
|
||||
private ITileDataSink mTileDataSink;
|
||||
private double mTileY, mTileX, mTileScale;
|
||||
|
||||
public OMDBReferenceDecoder() {
|
||||
super();
|
||||
mLocale = "";
|
||||
mGeomFactory = new GeometryFactory();
|
||||
mMapElement = new MapElement();
|
||||
mMapElement.layer = 5;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean decode(Tile tile, ITileDataSink sink, InputStream is) throws IOException {
|
||||
mTileDataSink = sink;
|
||||
mTileScale = 1 << tile.zoomLevel;
|
||||
mTileX = tile.tileX / mTileScale;
|
||||
mTileY = tile.tileY / mTileScale;
|
||||
mTileScale *= Tile.SIZE;
|
||||
return true;
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.N)
|
||||
public boolean decode(Tile tile, ITileDataSink sink, List<ReferenceEntity> listResult) {
|
||||
mTileDataSink = sink;
|
||||
mTileScale = 1 << tile.zoomLevel;
|
||||
mTileX = tile.tileX / mTileScale;
|
||||
mTileY = tile.tileY / mTileScale;
|
||||
mTileScale *= Tile.SIZE;
|
||||
|
||||
listResult.stream().iterator().forEachRemaining(new Consumer<ReferenceEntity>() {
|
||||
@Override
|
||||
public void accept(ReferenceEntity renderEntity) {
|
||||
// Log.d("RealmDBTileDataSource", renderEntity.getGeometry());
|
||||
Map<String, Object> properties= new HashMap<>(renderEntity.getProperties().size());
|
||||
properties.putAll(renderEntity.getProperties());
|
||||
parseGeometry(renderEntity.getTable(), renderEntity.getWkt(), properties);
|
||||
}
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
public void parseGeometry(String layerName, Geometry geometry, Map<String, Object> tags) {
|
||||
mMapElement.clear();
|
||||
mMapElement.tags.clear();
|
||||
|
||||
parseTags(tags, layerName);
|
||||
if (mMapElement.tags.size() == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
boolean err = false;
|
||||
if (geometry instanceof Point) {
|
||||
mMapElement.startPoints();
|
||||
processCoordinateArray(geometry.getCoordinates(), false);
|
||||
} else if (geometry instanceof MultiPoint) {
|
||||
MultiPoint multiPoint = (MultiPoint) geometry;
|
||||
for (int i = 0; i < multiPoint.getNumGeometries(); i++) {
|
||||
mMapElement.startPoints();
|
||||
processCoordinateArray(multiPoint.getGeometryN(i).getCoordinates(), false);
|
||||
}
|
||||
} else if (geometry instanceof LineString) {
|
||||
processLineString((LineString) geometry);
|
||||
} else if (geometry instanceof MultiLineString) {
|
||||
MultiLineString multiLineString = (MultiLineString) geometry;
|
||||
for (int i = 0; i < multiLineString.getNumGeometries(); i++) {
|
||||
processLineString((LineString) multiLineString.getGeometryN(i));
|
||||
}
|
||||
} else if (geometry instanceof Polygon) {
|
||||
Polygon polygon = (Polygon) geometry;
|
||||
processPolygon(polygon);
|
||||
} else if (geometry instanceof MultiPolygon) {
|
||||
MultiPolygon multiPolygon = (MultiPolygon) geometry;
|
||||
for (int i = 0; i < multiPolygon.getNumGeometries(); i++) {
|
||||
processPolygon((Polygon) multiPolygon.getGeometryN(i));
|
||||
}
|
||||
} else {
|
||||
err = true;
|
||||
}
|
||||
|
||||
if (!err) {
|
||||
mTileDataSink.process(mMapElement);
|
||||
}
|
||||
}
|
||||
|
||||
private void processLineString(LineString lineString) {
|
||||
mMapElement.startLine();
|
||||
processCoordinateArray(lineString.getCoordinates(), false);
|
||||
}
|
||||
|
||||
private void processPolygon(Polygon polygon) {
|
||||
mMapElement.startPolygon();
|
||||
processCoordinateArray(polygon.getExteriorRing().getCoordinates(), true);
|
||||
for (int i = 0; i < polygon.getNumInteriorRing(); i++) {
|
||||
mMapElement.startHole();
|
||||
processCoordinateArray(polygon.getInteriorRingN(i).getCoordinates(), true);
|
||||
}
|
||||
}
|
||||
|
||||
private void processCoordinateArray(Coordinate[] coordinates, boolean removeLast) {
|
||||
int length = removeLast ? coordinates.length - 1 : coordinates.length;
|
||||
for (int i = 0; i < length; i++) {
|
||||
mMapElement.addPoint((float) ((longitudeToX(coordinates[i].x) - mTileX) * mTileScale),
|
||||
(float) ((latitudeToY(coordinates[i].y) - mTileY) * mTileScale));
|
||||
}
|
||||
|
||||
// int length = removeLast ? coordinates.length - 1 : coordinates.length;
|
||||
// // 初始化3D数据类型
|
||||
// float[] point3D = new float[coordinates.length*3];
|
||||
// for (int i = 0; i < length; i++) {
|
||||
// point3D[i*3] = (float) coordinates[i].x;
|
||||
// point3D[(i*3)+1] = (float) coordinates[i].y;
|
||||
// point3D[(i*3)+2] = (float) coordinates[i].z;
|
||||
// }
|
||||
// mMapElement.points = point3D;
|
||||
// mMapElement.pointNextPos = mMapElement.points.length;
|
||||
// mMapElement.type = GeometryBuffer.GeometryType.TRIS;
|
||||
}
|
||||
|
||||
private void parseTags(Map<String, Object> map, String layerName) {
|
||||
mMapElement.tags.add(new Tag("layer", layerName));
|
||||
boolean hasName = false;
|
||||
String fallbackName = null;
|
||||
for (Map.Entry<String, Object> entry : map.entrySet()) {
|
||||
String key = entry.getKey();
|
||||
Object value = entry.getValue();
|
||||
String val = (value instanceof String) ? (String) value : String.valueOf(value);
|
||||
if (key.startsWith(Tag.KEY_NAME)) {
|
||||
int len = key.length();
|
||||
if (len == 4) {
|
||||
fallbackName = val;
|
||||
continue;
|
||||
}
|
||||
if (len < 7)
|
||||
continue;
|
||||
if (mLocale.equals(key.substring(5))) {
|
||||
hasName = true;
|
||||
mMapElement.tags.add(new Tag(Tag.KEY_NAME, val, false));
|
||||
}
|
||||
} else {
|
||||
mMapElement.tags.add(new Tag(key, val));
|
||||
}
|
||||
}
|
||||
if (!hasName && fallbackName != null)
|
||||
mMapElement.tags.add(new Tag(Tag.KEY_NAME, fallbackName, false));
|
||||
}
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
package com.navinfo.collect.library.map.source;
|
||||
|
||||
import com.navinfo.collect.library.system.Constant;
|
||||
|
||||
import org.oscim.tiling.ITileDataSource;
|
||||
import org.oscim.tiling.OverzoomTileDataSource;
|
||||
import org.oscim.tiling.TileSource;
|
||||
|
||||
public class OMDBReferenceTileSource extends TileSource {
|
||||
|
||||
@Override
|
||||
public ITileDataSource getDataSource() {
|
||||
return new OverzoomTileDataSource(new OMDBReferenceDataSource(), Constant.OVER_ZOOM);
|
||||
}
|
||||
|
||||
@Override
|
||||
public OpenResult open() {
|
||||
return OpenResult.SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user