diff --git a/.gitignore b/.gitignore index 8ccc4f86..f6c5d058 100644 --- a/.gitignore +++ b/.gitignore @@ -12,5 +12,4 @@ /build /captures .externalNativeBuild -.cxx -local.properties +.cxx \ No newline at end of file diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 00000000..5c54078a --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "vtm"] + path = vtm + url = git@github.com:mapsforge/vtm.git diff --git a/app/src/main/assets/omdb_config.json b/app/src/main/assets/omdb_config.json index 1e7d2c80..283ad4fd 100644 --- a/app/src/main/assets/omdb_config.json +++ b/app/src/main/assets/omdb_config.json @@ -75,6 +75,12 @@ "v": "0", "klib": "maxSpeed", "vlib": "限" + }, + { + "k": "geometry", + "v": "~", + "klib": "geometry", + "vlib": "translateRight()" } ] }, @@ -119,7 +125,28 @@ "4006":{ "table": "OMDB_RESTRICTION", "code": 4006, - "name": "普通交限" + "name": "普通交限", + "transformer": [ + { + "k": "geometry", + "v": "~", + "klib": "geometry", + "vlib": "translateRightWithAngle()" + } + ] + }, + "4022": { + "table": "OMDB_TRAFFICLIGHT", + "code": 4022, + "name": "交通灯", + "transformer": [ + { + "k": "angle", + "v": "~", + "klib": "angle", + "vlib": "0" + } + ] }, "4022":{ "table": "OMDB_TRAFFICLIGHT", @@ -131,6 +158,5 @@ "code": 5001, "name": "车道中心线" } - } } \ No newline at end of file diff --git a/app/src/main/java/com/navinfo/omqs/Constant.kt b/app/src/main/java/com/navinfo/omqs/Constant.kt index da0dca8c..ed6d845b 100644 --- a/app/src/main/java/com/navinfo/omqs/Constant.kt +++ b/app/src/main/java/com/navinfo/omqs/Constant.kt @@ -75,7 +75,7 @@ class Constant { const val SELECT_TAKEPHOTO_OR_RECORD = "select_takephoto_or_record" const val OMDB_CONFIG = "omdb_config.json" - const val OTHER_CONFIG = "other.config" + const val OTHER_CONFIG = "other_config.json" val OMDB_LAYER_VISIBLE_LIST: MutableList = mutableListOf() // 记录OMDB数据显示的图层名称列表 diff --git a/app/src/main/java/com/navinfo/omqs/bean/ImportConfig.kt b/app/src/main/java/com/navinfo/omqs/bean/ImportConfig.kt index ed5ba35a..1e15ce0d 100644 --- a/app/src/main/java/com/navinfo/omqs/bean/ImportConfig.kt +++ b/app/src/main/java/com/navinfo/omqs/bean/ImportConfig.kt @@ -32,23 +32,25 @@ class ImportConfig { } // 开始解析key和value,并对数据进行匹配 m@ for (k in processKeyOrValue(key)) { - for (v in processKeyOrValue(value)) { - if ("~" == v &&renderEntity.properties.containsKey(k)) { // ~符可以匹配任意元素 - if (valuelib.endsWith("()")) { // 以()结尾,说明该value配置是一个function,需要通过反射调用指定方法 - val method = preProcess::class.declaredMemberFunctions.first { it.name == valuelib.replace("()", "") } - method.call(preProcess, renderEntity) - } else { - renderEntity.properties[keylib] = valuelib + if (renderEntity.properties.containsKey(k)) { // json配置的key可以匹配到数据 + for (v in processKeyOrValue(value)) { + if ("~" == v ) { // ~符可以匹配任意元素 + if (valuelib.endsWith("()")) { // 以()结尾,说明该value配置是一个function,需要通过反射调用指定方法 + val method = preProcess::class.declaredMemberFunctions.first { it.name == valuelib.replace("()", "") } + method.call(preProcess, renderEntity) + } else { + renderEntity.properties[keylib] = valuelib + } + break@m + } else if (renderEntity.properties[k] == v) { // 完全匹配 + if (valuelib.endsWith("()")) { // 以()结尾,说明该value配置是一个function,需要通过反射调用指定方法 + val method = preProcess::class.declaredMemberFunctions.first { it.name == valuelib.replace("()", "") } + method.call(preProcess, renderEntity) + } else { + renderEntity.properties[keylib] = valuelib + } + break@m } - break@m - } else if (renderEntity.properties[k] == v) { - if (valuelib.endsWith("()")) { // 以()结尾,说明该value配置是一个function,需要通过反射调用指定方法 - val method = preProcess::class.declaredMemberFunctions.first { it.name == valuelib.replace("()", "") } - method.call(preProcess, renderEntity) - } else { - renderEntity.properties[keylib] = valuelib - } - break@m } } } diff --git a/app/src/main/java/com/navinfo/omqs/db/ImportPreProcess.kt b/app/src/main/java/com/navinfo/omqs/db/ImportPreProcess.kt index ba4a91d7..51bebc84 100644 --- a/app/src/main/java/com/navinfo/omqs/db/ImportPreProcess.kt +++ b/app/src/main/java/com/navinfo/omqs/db/ImportPreProcess.kt @@ -1,6 +1,12 @@ package com.navinfo.omqs.db import com.navinfo.collect.library.data.entity.RenderEntity +import com.navinfo.collect.library.utils.GeometryTools +import org.locationtech.jts.algorithm.Angle +import org.locationtech.jts.geom.Coordinate +import org.locationtech.jts.geom.Geometry +import org.oscim.core.GeoPoint + class ImportPreProcess { /** @@ -11,4 +17,94 @@ class ImportPreProcess { renderEntity.properties["foo"] = "bar" return renderEntity } + + /** + * 计算指定数据指定方向的坐标 + * */ + fun translateRight(renderEntity: 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) { + val angle = if(renderEntity?.properties?.get("angle") == null) 0.0 else renderEntity?.properties?.get("angle")?.toDouble()!! + radian = Math.toRadians(angle) + } else if (Geometry.TYPENAME_LINESTRING == geometry?.geometryType) { + val p1: Coordinate = geometry.coordinates.get(geometry.coordinates.size - 2) + val p2: Coordinate = geometry.coordinates.get(geometry.coordinates.size - 1) + // 计算线段的方向 + radian = Angle.angle(p1, p2) + point = p2 + } + + // 计算偏移距离 + val dx: Double = GeometryTools.convertDistanceToDegree(3.0, geometry?.coordinate?.y!!) * Math.cos(radian) + val dy: Double = GeometryTools.convertDistanceToDegree(3.0, geometry?.coordinate?.y!!) * Math.sin(radian) + + // 计算偏移后的点 + val coord = + Coordinate(point.getX() + dy, point.getY() - dx) + + // 将这个点记录在数据中 + val geometryTranslate: Geometry = GeometryTools.createGeometry(doubleArrayOf(coord.x, coord.y)) + renderEntity.geometry = geometryTranslate.toString() + return renderEntity + } + + /** + * 将要素按照点位角度的垂直方向右移5米,并生成一个按照垂直角度指向方向的线段,用以显示有方向的图标 + * */ + fun translateRightWithAngle(renderEntity: 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) { + val angle = if(renderEntity?.properties?.get("angle") == null) 0.0 else renderEntity?.properties?.get("angle")?.toDouble()!! + radian = Math.toRadians(angle) + } else if (Geometry.TYPENAME_LINESTRING == geometry?.geometryType) { + val p1: Coordinate = geometry.coordinates.get(geometry.coordinates.size - 2) + val p2: Coordinate = geometry.coordinates.get(geometry.coordinates.size - 1) + // 计算线段的方向 + radian = Angle.angle(p1, p2) + point = p2 + } + + // 根据角度计算偏移距离 + val dx: Double = GeometryTools.convertDistanceToDegree(3.0, geometry?.coordinate?.y!!) * Math.cos(radian) + val dy: Double = GeometryTools.convertDistanceToDegree(3.0, geometry?.coordinate?.y!!) * Math.sin(radian) + + // 计算偏移后的点 +// val coordMid = +// Coordinate(point.getX() + dy, point.getY() - dx) + 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) + + // 将这个线记录在数据中 + val geometryTranslate: Geometry = GeometryTools.createLineString(listOf(pointStart, pointEnd)) + renderEntity.geometry = geometryTranslate.toString() + return renderEntity + } + + fun addAngleFromGeometry(renderEntity: RenderEntity): String { + if (!renderEntity.properties.containsKey("angle")) { + if (renderEntity.wkt!=null) { + val geometry = renderEntity.wkt + var angle: String = "90" + if (geometry?.numPoints!!>=2) { + val p1: Coordinate = geometry?.coordinates?.get(geometry.coordinates.size - 2)!! + val p2: Coordinate = geometry?.coordinates?.get(geometry.coordinates.size - 1)!! + // 弧度转角度 + angle = Math.toDegrees(Angle.angle(p1, p2)).toString() + } else { + angle = "90" + } + // 计算线段的方向 + renderEntity.properties["angle"] = angle + return angle + } + } + return "0" + } } \ No newline at end of file diff --git a/app/src/main/java/com/navinfo/omqs/rule/LeftPanel.kt b/app/src/main/java/com/navinfo/omqs/rule/LeftPanel.kt deleted file mode 100644 index e4214c05..00000000 --- a/app/src/main/java/com/navinfo/omqs/rule/LeftPanel.kt +++ /dev/null @@ -1,5 +0,0 @@ -package com.navinfo.omqs.rule - -class LeftPanel { - -} \ No newline at end of file diff --git a/app/src/main/java/com/navinfo/omqs/ui/activity/login/LoginViewModel.kt b/app/src/main/java/com/navinfo/omqs/ui/activity/login/LoginViewModel.kt index bfbd5c4e..720fd20b 100644 --- a/app/src/main/java/com/navinfo/omqs/ui/activity/login/LoginViewModel.kt +++ b/app/src/main/java/com/navinfo/omqs/ui/activity/login/LoginViewModel.kt @@ -182,9 +182,9 @@ class LoginViewModel @Inject constructor( Realm.setDefaultConfiguration(config) // 拷贝配置文件到用户目录下 val omdbConfigFile = File(userFolder.absolutePath, Constant.OMDB_CONFIG); - if (!omdbConfigFile.exists()) { +// if (!omdbConfigFile.exists()) { ResourceUtils.copyFileFromAssets(Constant.OMDB_CONFIG, omdbConfigFile.absolutePath) - } +// } } /** diff --git a/app/src/main/java/com/navinfo/omqs/ui/fragment/personalcenter/PersonalCenterFragment.kt b/app/src/main/java/com/navinfo/omqs/ui/fragment/personalcenter/PersonalCenterFragment.kt index b0d14d37..1e5e5a81 100644 --- a/app/src/main/java/com/navinfo/omqs/ui/fragment/personalcenter/PersonalCenterFragment.kt +++ b/app/src/main/java/com/navinfo/omqs/ui/fragment/personalcenter/PersonalCenterFragment.kt @@ -111,7 +111,7 @@ class PersonalCenterFragment : BaseFragment(), FSAFActivityCallbacks { viewModel.readRealmData() // 定位到指定位置 niMapController.mMapView.vtmMap.animator() - .animateTo(GeoPoint(40.1012346774074730, 116.25571303257621)) + .animateTo(GeoPoint(28.724637921467508 ,115.83412668023867 )) } R.id.personal_center_menu_task_list -> { findNavController().navigate(R.id.TaskManagerFragment) diff --git a/build.gradle b/build.gradle index 0a318d80..5900d1f1 100644 --- a/build.gradle +++ b/build.gradle @@ -8,9 +8,14 @@ buildscript { } } plugins { - id 'com.android.application' version '7.3.1' apply false - id 'com.android.library' version '7.3.1' apply false + id 'com.android.application' version '7.4.2' apply false + id 'com.android.library' version '7.4.2' apply false id 'org.jetbrains.kotlin.android' version '1.8.0' apply false id 'com.google.dagger.hilt.android' version '2.44' apply false - } +static def androidCompileSdk() { return 33 } +allprojects { + ext.gdxVersion = "1.11.0" + ext.gwtVersion = "2.8.2" + ext.slf4jVersion = "1.7.28" +} \ No newline at end of file diff --git a/collect-library/build.gradle b/collect-library/build.gradle index 85910984..eb29aaa7 100644 --- a/collect-library/build.gradle +++ b/collect-library/build.gradle @@ -45,6 +45,12 @@ android { sourceSets { main { jniLibs.srcDirs = ['libs'] + file("../vtm/vtm-android/natives").eachDir() { dir -> + jniLibs.srcDirs += "${dir.path}/lib" + } + file("../vtm/vtm-android-gdx/natives").eachDir() { dir -> + jniLibs.srcDirs += "${dir.path}/lib" + } } } } @@ -72,25 +78,34 @@ dependencies { // VTM依赖 implementation "net.sf.kxml:kxml2:2.3.0" implementation 'org.slf4j:slf4j-api:2.0.7' - api "org.mapsforge:vtm:$vtmVersion" - implementation "org.mapsforge:vtm-themes:$vtmVersion" - implementation "org.mapsforge:vtm-android:$vtmVersion" - runtimeOnly "org.mapsforge:vtm-android:$vtmVersion:natives-armeabi-v7a" - runtimeOnly "org.mapsforge:vtm-android:$vtmVersion:natives-arm64-v8a" - runtimeOnly "org.mapsforge:vtm-android:$vtmVersion:natives-x86" - runtimeOnly "org.mapsforge:vtm-android:$vtmVersion:natives-x86_64" - implementation "org.mapsforge:vtm-http:$vtmVersion" + implementation project(":vtm-themes") + implementation project(":vtm-android") + implementation project(':vtm-extras') + implementation project(":vtm-http") +// implementation "org.mapsforge:vtm-themes:$vtmVersion" +// implementation "org.mapsforge:vtm-android:$vtmVersion" +// runtimeOnly "org.mapsforge:vtm-android:$vtmVersion:natives-armeabi-v7a" +// runtimeOnly "org.mapsforge:vtm-android:$vtmVersion:natives-arm64-v8a" +// runtimeOnly "org.mapsforge:vtm-android:$vtmVersion:natives-x86" +// runtimeOnly "org.mapsforge:vtm-android:$vtmVersion:natives-x86_64" +// implementation "org.mapsforge:vtm-http:$vtmVersion" - implementation "org.mapsforge:vtm-json:$vtmVersion" - implementation "org.mapsforge:vtm-gdx:$vtmVersion" - implementation "org.mapsforge:vtm-android-mvt:$vtmVersion" - implementation "org.mapsforge:vtm-mvt:$vtmVersion" + implementation project(":vtm-json") +// implementation project(":vtm-gdx") +// implementation project(":vtm-gdx-poi3d") + implementation project(":vtm-android-mvt") + implementation project(":vtm-mvt") +// implementation "org.mapsforge:vtm-json:$vtmVersion" +// implementation "org.mapsforge:vtm-gdx:$vtmVersion" +// implementation "org.mapsforge:vtm-android-mvt:$vtmVersion" +// implementation "org.mapsforge:vtm-mvt:$vtmVersion" - runtimeOnly "org.mapsforge:vtm-android-gdx:$vtmVersion:natives-armeabi-v7a" - runtimeOnly "org.mapsforge:vtm-android-gdx:$vtmVersion:natives-arm64-v8a" - runtimeOnly "org.mapsforge:vtm-android-gdx:$vtmVersion:natives-x86" - runtimeOnly "org.mapsforge:vtm-android-gdx:$vtmVersion:natives-x86_64" - implementation "org.mapsforge:vtm-android-gdx:$vtmVersion" +// implementation project(":vtm-android-gdx") +// runtimeOnly "org.mapsforge:vtm-android-gdx:$vtmVersion:natives-armeabi-v7a" +// runtimeOnly "org.mapsforge:vtm-android-gdx:$vtmVersion:natives-arm64-v8a" +// runtimeOnly "org.mapsforge:vtm-android-gdx:$vtmVersion:natives-x86" +// runtimeOnly "org.mapsforge:vtm-android-gdx:$vtmVersion:natives-x86_64" +// implementation "org.mapsforge:vtm-android-gdx:$vtmVersion" implementation "com.google.protobuf:protobuf-java:3.6.1" implementation "com.wdtinc:mapbox-vector-tile:3.1.0" @@ -98,7 +113,8 @@ dependencies { implementation "com.badlogicgames.gdx:gdx:1.11.0" implementation "com.badlogicgames.gdx:gdx-backend-android:1.11.0" implementation "com.caverock:androidsvg:1.4" - api "org.mapsforge:vtm-jts:$vtmVersion" +// api "org.mapsforge:vtm-jts:$vtmVersion" + api project(":vtm-jts") api 'org.locationtech.jts:jts-core:1.19.0' implementation 'com.squareup.okhttp3:okhttp:5.0.0-alpha.11' implementation 'com.squareup.okio:okio:3.3.0' diff --git a/collect-library/resources/rendertheme.xsd b/collect-library/resources/rendertheme.xsd index d77fee4f..3d4d76c5 100644 --- a/collect-library/resources/rendertheme.xsd +++ b/collect-library/resources/rendertheme.xsd @@ -94,6 +94,7 @@ + diff --git a/collect-library/src/main/assets/editormarker.xml b/collect-library/src/main/assets/editormarker.xml index 065193c8..d8d52cf1 100644 --- a/collect-library/src/main/assets/editormarker.xml +++ b/collect-library/src/main/assets/editormarker.xml @@ -1730,7 +1730,7 @@ stroke-width="1.0"> - @@ -1818,14 +1818,14 @@ - - - - - + @@ -1868,5 +1868,16 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/collect-library/src/main/assets/omdb/icon_4006_0.png b/collect-library/src/main/assets/omdb/icon_4006_0.png new file mode 100644 index 00000000..5c912a60 Binary files /dev/null and b/collect-library/src/main/assets/omdb/icon_4006_0.png differ diff --git a/collect-library/src/main/assets/omdb/icon_4022_0.png b/collect-library/src/main/assets/omdb/icon_4022_0.png new file mode 100644 index 00000000..a718c8e2 Binary files /dev/null and b/collect-library/src/main/assets/omdb/icon_4022_0.png differ diff --git a/collect-library/src/main/java/com/navinfo/collect/library/data/entity/RenderEntity.kt b/collect-library/src/main/java/com/navinfo/collect/library/data/entity/RenderEntity.kt index 853ab265..a799e01c 100644 --- a/collect-library/src/main/java/com/navinfo/collect/library/data/entity/RenderEntity.kt +++ b/collect-library/src/main/java/com/navinfo/collect/library/data/entity/RenderEntity.kt @@ -22,7 +22,7 @@ open class RenderEntity() : RealmObject() { lateinit var name: String //要素名 lateinit var table: String //要素表名 var code: Int = 0 // 要素编码 - var geometry: String = "" + var geometry: String = "" // 要素渲染参考的geometry,该数据可能会在导入预处理环节被修改,原始geometry会保存在properties的geometry字段下 get() { wkt = GeometryTools.createGeometry(field) return field diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index fce747eb..690a555d 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ #Tue Mar 21 10:15:37 CST 2023 distributionBase=GRADLE_USER_HOME -distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip distributionPath=wrapper/dists zipStorePath=wrapper/dists zipStoreBase=GRADLE_USER_HOME diff --git a/settings.gradle b/settings.gradle index b39629d4..edc00b4f 100644 --- a/settings.gradle +++ b/settings.gradle @@ -30,5 +30,46 @@ dependencyResolutionManagement { } } rootProject.name = "OMQualityInspection" + include ':app' include ':collect-library' +//include ':vtm:vtm' +//include ':vtm:vtm-android' +//include ':vtm:vtm-android-gdx' +//include ':vtm:vtm-android-mvt' +//include ':vtm:vtm-extras' +//include ':vtm:vtm-gdx' +//include ':vtm:vtm-gdx-poi3d' +//include ':vtm:vtm-http' +//include ':vtm:vtm-json' +//include ':vtm:vtm-jts' +//include ':vtm:vtm-models' +//include ':vtm:vtm-mvt' +//include ':vtm:vtm-theme-comparator' +//include ':vtm:vtm-themes' +include ':vtm' +include ':vtm-models' +include ':vtm-themes' +include ':vtm-android-mvt' +include ':vtm-android-gdx' +include ':vtm-android' +include ':vtm-mvt' +include ':vtm-gdx' +include ':vtm-jts' +include ':vtm-http' +include ':vtm-json' +include ':vtm-extras' +include ':vtm-gdx-poi3d' +project(':vtm').projectDir = new File(rootDir, 'vtm/vtm/') +project(':vtm-models').projectDir = new File(rootDir, 'vtm/vtm-models/') +project(':vtm-themes').projectDir = new File(rootDir, 'vtm/vtm-themes/') +project(':vtm-android-mvt').projectDir = new File(rootDir, 'vtm/vtm-android-mvt/') +project(':vtm-android-gdx').projectDir = new File(rootDir, 'vtm/vtm-android-gdx/') +project(':vtm-android').projectDir = new File(rootDir, 'vtm/vtm-android/') +project(':vtm-mvt').projectDir = new File(rootDir, 'vtm/vtm-mvt/') +project(':vtm-gdx').projectDir = new File(rootDir, 'vtm/vtm-gdx/') +project(':vtm-jts').projectDir = new File(rootDir, 'vtm/vtm-jts/') +project(':vtm-http').projectDir = new File(rootDir, 'vtm/vtm-http/') +project(':vtm-json').projectDir = new File(rootDir, 'vtm/vtm-json/') +project(':vtm-extras').projectDir = new File(rootDir, 'vtm/vtm-extras/') +project(':vtm-gdx-poi3d').projectDir = new File(rootDir, 'vtm/vtm-gdx-poi3d/') diff --git a/vtm b/vtm new file mode 160000 index 00000000..dd13e533 --- /dev/null +++ b/vtm @@ -0,0 +1 @@ +Subproject commit dd13e533c38b5738ab404c2737d7ccadeff01323