This commit is contained in:
qiji4215 2023-08-10 10:56:52 +08:00
commit 96316fe1bb
9 changed files with 134 additions and 13 deletions

View File

@ -544,6 +544,19 @@ class ImportPreProcess {
}
}
}
/**
* 生成默认路口数据的参考数据
* */
fun generateIntersectionDynamic(renderEntity: RenderEntity) {
// 路口数据的其他点位是保存在nodeList对应的数组下
if (renderEntity.properties.containsKey("type")) {
if (renderEntity.properties["type"] == "0") {
renderEntity.properties["typesrc"] = "assets:symbols/dot_blue_dark.svg"
} else {
renderEntity.properties["typesrc"] = "assets:symbols/volcano.svg"
}
}
}
/**
* 处理杆状物的高程数据

View File

@ -107,7 +107,7 @@ class TaskDownloadScope(
if (status != FileDownloadStatus.LOADING && status != FileDownloadStatus.IMPORTING) {
val realm = Realm.getDefaultInstance()
realm.executeTransaction {
it.copyToRealmOrUpdate(taskBean)
it.insertOrUpdate(taskBean)
}
}
}

View File

@ -123,7 +123,8 @@ class PersonalCenterFragment(private var indoorDataListener: ((Boolean) -> Unit?
//116.25017070328308 40.061730653134696
// 定位到指定位置
niMapController.mMapView.vtmMap.animator()
.animateTo(GeoPoint( 40.055878135289966, 116.3011588289057 ))
// .animateTo(GeoPoint( 40.05108004733645, 116.29187746293708 ))
.animateTo(GeoPoint( 39.91975038055932,116.35447089476969 ))
}
// R.id.personal_center_menu_task_list -> {
// findNavController().navigate(R.id.TaskManagerFragment)

View File

@ -169,6 +169,12 @@ class PersonalCenterViewModel @Inject constructor(
importOMDBHelper.importOmdbZipFile(importOMDBHelper.omdbFile, task).collect {
Log.d("importOMDBData", it)
}
} else {
val newTask = TaskBean()
newTask.id = 9999
importOMDBHelper.importOmdbZipFile(importOMDBHelper.omdbFile, newTask).collect {
Log.d("importOMDBData", it)
}
}
Log.d("OMQSApplication", "导入数据完成")
}

View File

@ -0,0 +1,97 @@
package com.navinfo.omqs;
import org.junit.Test;
import java.util.ArrayList;
import java.util.List;
public class ParallelRectangleAlgorithm {
public static List<Point> getParallelRectanglePoints(List<Point> polygon) {
// Step 1: Get the first two points of the polygon to form a line
List<Point> line = new ArrayList<>();
line.add(polygon.get(0));
line.add(polygon.get(1));
// Step 2: Find the points on the opposite side or farther away from the line
List<Point> farPoints = new ArrayList<>();
for (int i = 2; i < polygon.size(); i++) {
Point point = polygon.get(i);
int side = getSide(line.get(0), line.get(1), point);
double distance = getDistance(line.get(0), line.get(1), point);
if (side != 0 && side != Math.signum(distance)) {
farPoints.add(point);
}
}
// Step 3: Find the perpendicular lines to the first line passing through the farthest points
List<Point> perpendicularLines = new ArrayList<>();
for (Point farPoint : farPoints) {
double dx = line.get(1).getY() - line.get(0).getY();
double dy = line.get(0).getX() - line.get(1).getX();
double magnitude = Math.sqrt(dx * dx + dy * dy);
dx /= magnitude;
dy /= magnitude;
double distance = Math.abs((farPoint.getX() - line.get(0).getX()) * dx + (farPoint.getY() - line.get(0).getY()) * dy);
Point perpendicularLine = new Point(farPoint.getX() + distance * dx, farPoint.getY() + distance * dy);
perpendicularLines.add(perpendicularLine);
}
// Step 4: Find the intersection points of the perpendicular lines
List<Point> intersectionPoints = new ArrayList<>();
for (int i = 0; i < perpendicularLines.size(); i++) {
for (int j = i + 1; j < perpendicularLines.size(); j++) {
Point intersectionPoint = getIntersectionPoint(line.get(0), perpendicularLines.get(i), line.get(1), perpendicularLines.get(j));
intersectionPoints.add(intersectionPoint);
}
}
return intersectionPoints;
}
private static int getSide(Point p1, Point p2, Point point) {
return Integer.signum((int) Math.signum((p2.getX() - p1.getX()) * (point.getY() - p1.getY()) - (p2.getY() - p1.getY()) * (point.getX() - p1.getX())));
}
private static double getDistance(Point p1, Point p2, Point point) {
return ((p2.getX() - p1.getX()) * (point.getY() - p1.getY()) - (p2.getY() - p1.getY()) * (point.getX() - p1.getX())) / Math.sqrt((p2.getX() - p1.getX()) * (p2.getX() - p1.getX()) + (p2.getY() - p1.getY()) * (p2.getY() - p1.getY()));
}
private static Point getIntersectionPoint(Point p1, Point p2, Point p3, Point p4) {
double x1 = p1.getX();
double y1 = p1.getY();
double x2 = p2.getX();
double y2 = p2.getY();
double x3 = p3.getX();
double y3 = p3.getY();
double x4 = p4.getX();
double y4 = p4.getY();
double x = ((x2 - x1) * (x3 * y4 - x4 * y3) - (x4 - x3) * (x1 * y2 - x2 * y1)) / ((x2 - x1) * (y3 - y4) - (x4 - x3) * (y1 - y2));
double y = ((y3 - y4) * (x1 * y2 - x2 * y1) - (y1 - y2) * (x3 * y4 - x4 * y3)) / ((x2 - x1) * (y3 - y4) - (x4 - x3) * (y1 - y2));
return new Point(x, y);
}
@Test
public void test() {
List<Point> polygon = new ArrayList<>();
polygon.add(new Point(0, 0));
polygon.add(new Point(2, 0));
polygon.add(new Point(2, 1));
polygon.add(new Point(1, 1));
polygon.add(new Point(1, 2));
polygon.add(new Point(0, 2));
List<Point> result = getParallelRectanglePoints(polygon);
for (Point point : result) {
System.out.println(point);
}
}
}
class Point {
private double x;
private double y;
public Point(double x, double y) {
this.x = x;
this.y = y;
}
public double getX() {
return x;
}
public double getY() {
return y;
}
@Override
public String toString() {
return "(" + x + ", " + y + ")";
}
}

View File

@ -1482,10 +1482,10 @@
</m>
<m k="qi_table">
<!-- 道路线 -->
<!-- <m v="OMDB_RD_LINK">
<line stroke="#9c9c9c" width="1" />
</m>-->
<!-- &lt;!&ndash; 道路线 &ndash;&gt;-->
<!-- <m v="OMDB_RD_LINK">-->
<!-- <line stroke="#9c9c9c" width="1" />-->
<!-- </m>-->
<!--道路种别-->
<m v="OMDB_RD_LINK_KIND">
@ -1951,15 +1951,19 @@
</m>
<m v="OMDB_AREA">
<area use="sign-bg" repeat="true" src="assets:omdb/area_test.jpg" stroke="#ff0000" stroke-width="2"></area>
<!-- <area use="sign-bg" repeat="false" src="assets:omdb/veer_side_walk.jpg" stroke="#ff0000" stroke-width="2"></area>-->
<area use="sign-bg" repeat="false" src="@text:人行横道" stroke="#ff0000" stroke-width="2"></area>
</m>
<!-- 路口 -->
<m v="OMDB_INTERSECTION">
<m k="type" v="node">
<symbol src="assets:symbols/dot_blue_dark.svg"></symbol>
</m>
<m k="intersectionPid">
<symbol src="assets:symbols/dot_magenta.svg"></symbol>
<!-- <m k="type" v="node">-->
<!-- <symbol src="assets:symbols/dot_blue_dark.svg"></symbol>-->
<!-- </m>-->
<!-- <m k="intersectionPid">-->
<!-- <symbol src="assets:symbols/dot_magenta.svg"></symbol>-->
<!-- </m>-->
<m k="geometry">
<symbol src="@typesrc"></symbol>
</m>
</m>

Binary file not shown.

After

Width:  |  Height:  |  Size: 96 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

2
vtm

@ -1 +1 @@
Subproject commit 8717b07ebff4dd61226abb19474be6567a736ad8
Subproject commit 58f231037c44ccc1c82d00818c402a2894ca4e09