Bladeren bron

模板文件放服务器, 当前项目路径+baseData

wuweihao 4 jaren geleden
bovenliggende
commit
a6d50ba133

+ 4 - 2
laser/src/main/java/com/fdkankan/indoor/base/constant/ConfigConstant.java

@@ -15,8 +15,10 @@ public class ConfigConstant {
     @Value("${server.file.path}")
     public  String serverBasePath;
 
-//    @Value("${server.file.allow}")
-//    public String serverFileFallow;
+
+    /** 数据模板路径*/
+    @Value("${my.template.path}")
+    public String templatePath;
 
     /**redis token前缀*/
 //    @Value("${redis.prefix}")

+ 10 - 3
laser/src/main/java/com/fdkankan/indoor/base/convert/GisCoordinateUtil.java

@@ -94,8 +94,12 @@ public class GisCoordinateUtil {
 
     public  static  void calculateVariable (double alon,double alat,double aX,double aY,double blon,double blat,double bX,double bY){
 
-        double[] a= GisCoordinateTransform.convertByProj4(alon,alat, coordCode4326, coordCode3857);
-        double[] b= GisCoordinateTransform.convertByProj4(blon,blat, coordCode4326, coordCode3857);
+//        double[] a= GisCoordinateTransform.convertByProj4(alon,alat, coordCode4326, coordCode3857);
+//        double[] b= GisCoordinateTransform.convertByProj4(blon,blat, coordCode4326, coordCode3857);
+
+        double[] a= GisCoordinateTransform.convert2000BLToGauss(alon,alat);
+        double[] b= GisCoordinateTransform.convert2000BLToGauss(blon,blat);
+
         dx=a[0]-aX;
         dy=a[1]-aY;
         locationplaneVector=new double[2];
@@ -132,8 +136,11 @@ public class GisCoordinateUtil {
         double x=resultX+dx;
         double y=resultY+dy;
 
+
+
 //        return GisCoordinateTransform.Convert2000GaussToBL(x,y,centerLon);
-        return GisCoordinateTransform.convertByProj4(x,y, coordCode3857, coordCode4326);
+//        return GisCoordinateTransform.convertByProj4(x,y, coordCode3857, coordCode4326);
+        return GisCoordinateTransform.convert2000GaussToBL(x,y,centerLon);
     }
 
 

+ 0 - 117
laser/src/main/java/com/fdkankan/indoor/base/util/DistanceUtil.java

@@ -1,117 +0,0 @@
-//package com.fdkankan.indoor.base.util;
-//
-//import java.awt.geom.Point2D;
-//import java.util.List;
-//
-///**
-// * @author Admin
-// * 距离计算
-// */
-//public class DistanceUtil {
-//
-//    public static double distance(Double[] coordinates1, Double[] coordinates2, Options options) {
-//        double dLat = degreesToRadians(coordinates2[1] - coordinates1[1]);
-//        double dLon = degreesToRadians(coordinates2[0] - coordinates1[0]);
-//        double lat1 = degreesToRadians(coordinates1[1]);
-//        double lat2 = degreesToRadians(coordinates2[1]);
-//
-//        double a = Math.pow(Math.sin(dLat / 2), 2) +
-//                        Math.pow(Math.sin(dLon / 2), 2) * Math.cos(lat1) * Math.cos(lat2);
-//
-//        return radiansToLength(
-//                2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a)),
-//                options.getUnits()
-//        );
-//    }
-//
-//
-//    public static double degreesToRadians(Double degrees) {
-//        if (degrees == null) {
-//            return 0.0D;
-//        }
-//        double radians = degrees % 360;
-//        return (radians * Math.PI) / 180;
-//    }
-//
-//    public static double radiansToLength(double radians, String units) {
-//        Double factor = Factors.getFactorsData(units);
-//        if (factor == null) {
-//            throw new RuntimeException(units + " units is invalid");
-//        }
-//        return radians * factor;
-//    }
-//
-//
-//    /**
-//     * 判断点是否在多边形内
-//     * @param point 检测点
-//     * @param pts   多边形的顶点
-//     * @return      点在多边形内返回true,否则返回false
-//     */
-//    public static boolean IsPtInPoly(Point2D.Double point, List<Point2D.Double> pts){
-//
-//        int N = pts.size();
-//        boolean boundOrVertex = true; //如果点位于多边形的顶点或边上,也算做点在多边形内,直接返回true
-//        int intersectCount = 0;//cross points count of x
-//        double precision = 2e-10; //浮点类型计算时候与0比较时候的容差
-//        Point2D.Double p1, p2;//neighbour bound vertices
-//        Point2D.Double p = point; //当前点
-//
-//        p1 = pts.get(0);//left vertex
-//        for(int i = 1; i <= N; ++i){//check all rays
-//            if(p.equals(p1)){
-//                return boundOrVertex;//p is an vertex
-//            }
-//
-//            p2 = pts.get(i % N);//right vertex
-//            if(p.x < Math.min(p1.x, p2.x) || p.x > Math.max(p1.x, p2.x)){//ray is outside of our interests
-//                p1 = p2;
-//                continue;//next ray left point
-//            }
-//
-//            if(p.x > Math.min(p1.x, p2.x) && p.x < Math.max(p1.x, p2.x)){//横坐标 内  ray is crossing over by the algorithm (common part of)
-//                if(p.y <= Math.max(p1.y, p2.y)){//y下  x is before of ray
-//                    if(p1.x == p2.x && p.y >= Math.min(p1.y, p2.y)){//overlies on a horizontal ray  垂线
-//                        return boundOrVertex;
-//                    }
-//
-//                    if(p1.y == p2.y){//水平线 ray is vertical
-//                        if(p1.y == p.y){//水平线内 overlies on a vertical ray
-//                            return boundOrVertex;
-//                        }else{//before ray
-//                            ++intersectCount;  //交点在上方
-//                        }
-//                    }else{//cross point on the left side
-//                        double xinters = (p.x - p1.x) * (p2.y - p1.y) / (p2.x - p1.x) + p1.y;//两点式化简,交点y坐标 cross point of y
-//                        if(Math.abs(p.y - xinters) < precision){//== 0  在线上  overlies on a ray
-//                            return boundOrVertex;
-//                        }
-//
-//                        if(p.y < xinters){//before ray
-//                            ++intersectCount;  //交点在上方
-//                        }
-//                    }
-//                }
-//            }else{//special case when ray is crossing through the vertex
-//                if(p.x == p2.x && p.y <= p2.y){//p crossing over p2
-//                    Point2D.Double p3 = pts.get((i+1) % N); //next vertex
-//                    if(p.x >= Math.min(p1.x, p3.x) && p.x <= Math.max(p1.x, p3.x)){//p.x lies between p1.x & p3.x
-//                        ++intersectCount;
-//                    }else{
-//                        intersectCount += 2;
-//                    }
-//                }
-//            }
-//            p1 = p2;//next ray left point
-//        }
-//
-//        if(intersectCount % 2 == 0){//偶数在多边形外
-//            return false;
-//        } else { //奇数在多边形内
-//            return true;
-//        }
-//
-//    }
-//
-//
-//}

+ 6 - 0
laser/src/main/java/com/fdkankan/indoor/core/controller/DateSetController.java

@@ -49,6 +49,12 @@ public class DateSetController {
     }
 
 
+    /**
+     * 返回对象
+     * @param sceneCode
+     * @param dataSetId
+     * @return
+     */
     @WebControllerLog(description = "场景信息接口-根据id查询")
     @ApiOperation(value = "根据id查询")
     @GetMapping("indoor/{sceneCode}/api/datasets/{dataSetId}")

+ 8 - 4
laser/src/main/java/com/fdkankan/indoor/core/service/impl/InitServiceImpl.java

@@ -465,7 +465,8 @@ public class InitServiceImpl implements InitService {
 
     private void createSiteModel(String sceneCode,  Double[] max,  Double[] min,  Double[] centre, Double maxZ, Double minZ){
         //读取初始文件
-        String content = MyFileUtils.getResourceContent("data/site_model.json");
+//        String content = MyFileUtils.getResourceContent("data/site_model.json");
+        String content = cn.hutool.core.io.FileUtil.readUtf8String(configConstant.templatePath + "/site_model.json");
         List<SiteDto> siteModels = JSON.parseArray(content, SiteDto.class);
         // z_max、z_min 替换site_model的Floor、root类型
         // max、min四个顶点替换BUILDING、FLOOR 的coordinates,
@@ -589,7 +590,8 @@ public class InitServiceImpl implements InitService {
         entity.setId(sceneCode);
         entity.setUpdateTime(LocalDateTime.now());
         // 读取初始文件
-        String resourceContent = MyFileUtils.getResourceContent("data/poi_type.json");
+//        String resourceContent = MyFileUtils.getResourceContent("data/poi_type.json");
+        String resourceContent = cn.hutool.core.io.FileUtil.readUtf8String(configConstant.templatePath + "/poi_type.json");
         List<PoiTypeDto> dtoList = com.alibaba.fastjson.JSONArray.parseArray(resourceContent, PoiTypeDto.class);
         entity.setData(dtoList);
         poiTypeService.save(entity);
@@ -601,7 +603,8 @@ public class InitServiceImpl implements InitService {
         entity.setId(sceneCode);
         entity.setUpdateTime(LocalDateTime.now());
         // 读取初始文件
-        String resourceContent = MyFileUtils.getResourceContent("data/poi_type.json");
+//        String resourceContent = MyFileUtils.getResourceContent("data/poi_type.json");
+        String resourceContent = cn.hutool.core.io.FileUtil.readUtf8String(configConstant.templatePath + "/poi_type_group.json");
         List<PoiTypeGroupDto> dtoList = com.alibaba.fastjson.JSONArray.parseArray(resourceContent, PoiTypeGroupDto.class);
         entity.setData(dtoList);
         poiTypeGroupService.save(entity);
@@ -654,7 +657,8 @@ public class InitServiceImpl implements InitService {
         Double[] poi = sp.getPoi();
         log.info("firstView: {}" , sp.getPoi());
 
-        String content = MyFileUtils.getResourceContent("data/config.json");
+//        String content = MyFileUtils.getResourceContent("data/config.json");
+        String content = cn.hutool.core.io.FileUtil.readUtf8String(configConstant.templatePath + "/config.json");
 
         List<ConfigDto> dtoList = com.alibaba.fastjson.JSONArray.parseArray(content, ConfigDto.class);
         List<ConfigDto> resData =  new ArrayList<>();

+ 15 - 0
laser/src/main/java/com/fdkankan/indoor/test/Demo.java

@@ -3,6 +3,9 @@ package com.fdkankan.indoor.test;
 import cn.hutool.core.io.FileUtil;
 import com.alibaba.fastjson.JSONArray;
 import org.junit.Test;
+import org.springframework.util.ResourceUtils;
+
+import java.io.FileNotFoundException;
 
 /**
  * Created by owen on 2021/7/15 0015 15:50
@@ -10,6 +13,7 @@ import org.junit.Test;
 public class Demo {
 
 
+
     @Test
     public void editFilter(){
         String path = "F:\\test\\age\\filter.json";
@@ -18,4 +22,15 @@ public class Demo {
         JSONArray array = JSONArray.parseArray(s);
         System.out.println(s);
     }
+
+
+    @Test
+    public void test(){
+
+//        String resourceContent = cn.hutool.core.io.FileUtil.readUtf8String("F:\\test\\project\\age_laser\\laserData\\baseData\\poi_type.json");
+        // 获取当前工程路径
+        String path = System.getProperty("user.dir");
+        System.out.println(path);
+
+    }
 }

+ 1 - 0
laser/src/main/resources/application-dev.properties

@@ -16,6 +16,7 @@ swagger.description=${swagger.title}
 swagger.version=1.0
 
 server.file.path=F:\\test\\ngin\\${project.en}_data
+my.template.path=F:/test/project/age_laser/laserData
 
 
 oss.point=http://oss-cn-shenzhen-internal.aliyuncs.com

+ 2 - 0
laser/src/main/resources/application-sit.properties

@@ -14,6 +14,8 @@ swagger.version=1.0
 
 # \u4E0A\u4F20\u6587\u4EF6\u4FDD\u5B58\u8DEF\u5F84
 server.file.path=/var/www/html/laser/maxkk
+# \u6A21\u677F\u6587\u4EF6\u4F4D\u7F6E
+my.template.path=/root/user/java/jar_run/baseData
 
 
 oss.point=http://oss-cn-shenzhen-internal.aliyuncs.com

+ 2 - 2
laser/src/main/resources/data/config.json

@@ -216,7 +216,7 @@
   },
   "id": 17,
   "name": "layers.map.visible",
-  "value": "false",
+  "value": "true",
   "type": "boolean",
   "length": null,
   "category": "layer.visibility",
@@ -818,7 +818,7 @@
   },
   "id": 65,
   "name": "core.map.map_names_save",
-  "value": "[{\"map_id\":\"data/bundle_4ab2a7c2-41a3-4394-b85c-f0267cb155d9/building_1/map_tiles/2\",\"floor_id\":2,\"map_name\":\"平面图2\",\"visbility\":true,\"position\":{\"x\":-14.344578783299346,\"y\":10.175606851823359,\"z\":-0.04499989722412112},\"rotation\":{\"x\":0,\"y\":0,\"z\":0},\"scale\":{\"x\":1,\"y\":1,\"z\":1}}]",
+  "value": "",
   "type": "string",
   "length": null,
   "category": "map.appearance",