feat: 面数据增加自适应纹理
This commit is contained in:
parent
0462a1682e
commit
958e94ea1e
@ -425,6 +425,30 @@ class ImportPreProcess {
|
||||
}
|
||||
|
||||
|
||||
// /**
|
||||
// * 生成默认路口数据的参考数据
|
||||
// * */
|
||||
// fun generateIntersectionReference(renderEntity: RenderEntity) {
|
||||
// // 路口数据的其他点位,是保存在nodeList对应的数组下
|
||||
// if (renderEntity.properties.containsKey("nodeList")) {
|
||||
// val nodeListJsonArray: JSONArray = JSONArray(renderEntity.properties["nodeList"])
|
||||
// for (i in 0 until nodeListJsonArray.length()) {
|
||||
// val nodeJSONObject = nodeListJsonArray.getJSONObject(i)
|
||||
// val intersectionReference = ReferenceEntity()
|
||||
// intersectionReference.renderEntityId = renderEntity.id
|
||||
// intersectionReference.name = "${renderEntity.name}参考点"
|
||||
// intersectionReference.table = renderEntity.table
|
||||
// intersectionReference.zoomMin = renderEntity.zoomMin
|
||||
// intersectionReference.zoomMax = renderEntity.zoomMax
|
||||
// intersectionReference.taskId = renderEntity.taskId
|
||||
// // 与原有方向指向平行的线
|
||||
// intersectionReference.geometry = GeometryTools.createGeometry(nodeJSONObject["geometry"].toString()).toString()
|
||||
// intersectionReference.properties["qi_table"] = renderEntity.table
|
||||
// intersectionReference.properties["type"] = "node"
|
||||
// Realm.getDefaultInstance().insert(intersectionReference)
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
/**
|
||||
* 生成默认路口数据的参考数据
|
||||
* */
|
||||
|
@ -126,7 +126,7 @@ class PersonalCenterFragment(private var indoorDataListener: ((Boolean) -> Unit?
|
||||
//116.25017070328308 40.061730653134696
|
||||
// 定位到指定位置
|
||||
niMapController.mMapView.vtmMap.animator()
|
||||
.animateTo(GeoPoint( 40.055878135289966, 116.3011588289057 ))
|
||||
.animateTo(GeoPoint( 39.91831047339841,116.36009639042146 ))
|
||||
}
|
||||
// R.id.personal_center_menu_task_list -> {
|
||||
// findNavController().navigate(R.id.TaskManagerFragment)
|
||||
|
@ -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 + ")";
|
||||
}
|
||||
}
|
@ -1951,7 +1951,7 @@
|
||||
</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/diversion_zone.jpg" stroke="#ff0000" stroke-width="2"></area>
|
||||
</m>
|
||||
<!-- 路口 -->
|
||||
<m v="OMDB_INTERSECTION">
|
||||
|
BIN
collect-library/src/main/assets/omdb/diversion_zone.jpg
Normal file
BIN
collect-library/src/main/assets/omdb/diversion_zone.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 96 KiB |
BIN
collect-library/src/main/assets/omdb/veer_side_walk.jpg
Normal file
BIN
collect-library/src/main/assets/omdb/veer_side_walk.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 36 KiB |
2
vtm
2
vtm
@ -1 +1 @@
|
||||
Subproject commit 4c9926d105877fce305025e8f85651ccea947c4f
|
||||
Subproject commit c2434827f1201a16a2120db777cd0aa8209c4682
|
Loading…
x
Reference in New Issue
Block a user