Browse Source

添加大场景编辑

wuweihao 3 years ago
parent
commit
425f5eec99
31 changed files with 23782 additions and 13 deletions
  1. 6 0
      gis_application/pom.xml
  2. 3 3
      gis_cms/src/main/java/com/gis/cms/controller/WebController.java
  3. 99 1
      gis_common/src/main/java/com/gis/common/base/exception/BaseRuntimeException.java
  4. 20 0
      gis_common/src/main/java/com/gis/common/util/BaseUtil.java
  5. 101 0
      gis_common/src/main/java/com/gis/common/util/DateUtils.java
  6. 52 9
      gis_common/src/main/java/com/gis/common/util/FileUtils.java
  7. 57 0
      gis_scene/pom.xml
  8. 98 0
      gis_scene/src/main/java/com/gis/scene/controller/SceneController.java
  9. 24 0
      gis_scene/src/main/java/com/gis/scene/entity/dto/RoamViableDto.java
  10. 38 0
      gis_scene/src/main/java/com/gis/scene/entity/dto/SceneDataDto.java
  11. 26 0
      gis_scene/src/main/java/com/gis/scene/entity/dto/ScenePageDto.java
  12. 63 0
      gis_scene/src/main/java/com/gis/scene/entity/po/SceneEntity.java
  13. 30 0
      gis_scene/src/main/java/com/gis/scene/mapper/SceneMapper.java
  14. 7340 0
      gis_scene/src/main/java/com/gis/scene/proto/BigSceneProto.java
  15. 4654 0
      gis_scene/src/main/java/com/gis/scene/proto/Common.java
  16. 4345 0
      gis_scene/src/main/java/com/gis/scene/proto/Visionmodeldata.java
  17. 37 0
      gis_scene/src/main/java/com/gis/scene/proto/constant/ConstantCmd.java
  18. 41 0
      gis_scene/src/main/java/com/gis/scene/proto/constant/ConstantFileName.java
  19. 61 0
      gis_scene/src/main/java/com/gis/scene/proto/constant/ConstantFilePath.java
  20. 156 0
      gis_scene/src/main/java/com/gis/scene/proto/format/CouchDBFormat.java
  21. 703 0
      gis_scene/src/main/java/com/gis/scene/proto/format/HtmlFormat.java
  22. 1338 0
      gis_scene/src/main/java/com/gis/scene/proto/format/JavaPropsFormat.java
  23. 1603 0
      gis_scene/src/main/java/com/gis/scene/proto/format/JsonFormat.java
  24. 602 0
      gis_scene/src/main/java/com/gis/scene/proto/format/SmileFormat.java
  25. 1333 0
      gis_scene/src/main/java/com/gis/scene/proto/format/XmlFormat.java
  26. 162 0
      gis_scene/src/main/java/com/gis/scene/proto/util/ConvertUtils.java
  27. 233 0
      gis_scene/src/main/java/com/gis/scene/proto/util/CreateObjUtil.java
  28. 61 0
      gis_scene/src/main/java/com/gis/scene/proto/util/StreamGobbler.java
  29. 37 0
      gis_scene/src/main/java/com/gis/scene/service/SceneService.java
  30. 453 0
      gis_scene/src/main/java/com/gis/scene/service/impl/SceneServiceImpl.java
  31. 6 0
      pom.xml

+ 6 - 0
gis_application/pom.xml

@@ -23,6 +23,12 @@
             <groupId>com.gis</groupId>
             <artifactId>gis_cms</artifactId>
         </dependency>
+
+
+        <dependency>
+            <groupId>com.gis</groupId>
+            <artifactId>gis_scene</artifactId>
+        </dependency>
     </dependencies>
 
     <build>

+ 3 - 3
gis_cms/src/main/java/com/gis/cms/controller/WebController.java

@@ -24,10 +24,10 @@ import javax.validation.Valid;
  * Created by owen on 2020/5/8 0008 9:54
  */
 @Slf4j
-@Api(tags = "web-展示页")
+@Api(tags = "show-展示页")
 @RestController
-@RequestMapping("web")
-public class WebController {
+@RequestMapping("/show")
+public class ShowController {
 
     @Autowired
     CommentService commentService;

+ 99 - 1
gis_common/src/main/java/com/gis/common/base/exception/BaseRuntimeException.java

@@ -1,5 +1,10 @@
 package com.gis.common.base.exception;
 
+import cn.hutool.core.util.StrUtil;
+import org.springframework.util.CollectionUtils;
+
+import java.util.List;
+
 public class BaseRuntimeException extends RuntimeException{
 
     private static final long serialVersionUID = -1518945670203783450L;
@@ -8,15 +13,26 @@ public class BaseRuntimeException extends RuntimeException{
 
     public BaseRuntimeException(String msg){
         super(msg);
+        this.code = -1;
         this.msg = msg;
     }
 
+    /**
+     *
+     * @param code 允许为null
+     * @param msg
+     */
     public BaseRuntimeException(Integer code, String msg){
         super(msg);
-        this.code = code;
+        this.code = code == null? -1 : code;
         this.msg = msg;
     }
 
+//    public BaseRuntimeException(ErrorEnum errorEnum){
+//        this.code = errorEnum.code();
+//        this.msg = errorEnum.message();
+//    }
+
     public Integer getCode() {
         return code;
     }
@@ -32,4 +48,86 @@ public class BaseRuntimeException extends RuntimeException{
     public void setMsg(String msg) {
         this.msg = msg;
     }
+
+
+    public static void isNull(Object obj, Integer code, String msg){
+        if (obj == null){
+            getExc(code, msg);
+        }
+    }
+
+    public static void isBlank(Object obj, Integer code, String msg){
+        if (obj == null){
+            getExc(code, msg);
+        }
+
+        if (obj instanceof String && StrUtil.isBlank(obj.toString())){
+            getExc(code, msg);
+        }
+
+    }
+
+//    public static void isNull(Object obj, ErrorEnum errorEnum){
+//        if (obj == null){
+//            getExc(errorEnum.code(), errorEnum.message());
+//        }
+//    }
+
+//    public static void isBlank(Object obj, ErrorEnum errorEnum){
+//        Integer code = errorEnum.code();
+//        String msg = errorEnum.message();
+//        if (obj == null){
+//            getExc(code, msg);
+//        }
+//
+//        if (obj instanceof String && StrUtil.isBlank(obj.toString())){
+//            getExc(code, msg);
+//        }
+//
+//    }
+
+    /**
+     *
+     * @param obj true 存在抛异常
+     * @param errorEnum
+     */
+//    public static void isTrue(boolean obj, ErrorEnum errorEnum){
+//        if (obj){
+//            getExc(errorEnum.code(), errorEnum.message());
+//        }
+//    }
+
+    /**
+     *
+     * @param obj 存在抛异常
+     * @param code 允许为null
+     * @param msg
+     */
+    public static void isTrue(boolean obj, Integer code, String msg){
+        if (obj){
+            getExc(code, msg);
+        }
+    }
+
+    public static void  getExc(Integer code, String msg){
+        throw new BaseRuntimeException(code, msg);
+    }
+
+//    /**
+//     *
+//     * @param obj 集合
+//     * @param errorEnum
+//     */
+//    public static void isEmpty(List obj, ErrorEnum errorEnum){
+//        if (CollectionUtils.isEmpty(obj)){
+//            getExc(errorEnum.code(), errorEnum.message());
+//        }
+//    }
+
+    public static void isEmpty(List obj, Integer code, String msg){
+        if (CollectionUtils.isEmpty(obj)){
+            getExc(code, msg);
+        }
+    }
+
 }

+ 20 - 0
gis_common/src/main/java/com/gis/common/util/BaseUtil.java

@@ -0,0 +1,20 @@
+package com.gis.common.util;
+
+import com.gis.common.base.entity.dto.PageDto;
+
+/**
+ * Created by owen on 2021/12/7 0007 16:21
+ */
+public class BaseUtil {
+
+    public static void startPage(PageDto param){
+        Integer pageNum = param.getPageNum();
+        Integer pageSize = param.getPageSize();
+        if (pageNum == null || pageNum <= 0) {
+            param.setPageNum(0);
+        }
+        if (pageSize == null || pageSize <= 0) {
+            param.setPageSize(10);
+        }
+    }
+}

+ 101 - 0
gis_common/src/main/java/com/gis/common/util/DateUtils.java

@@ -0,0 +1,101 @@
+package com.gis.common.util;
+
+import cn.hutool.core.date.DateUtil;
+import org.junit.Test;
+
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.LocalTime;
+import java.time.format.DateTimeFormatter;
+
+/**
+ * Created by owen on 2022/4/8 0008 14:32
+ */
+public class DateUtils extends DateUtil {
+
+    private static String YYYY_MM = "yyyy-MM";
+
+    private static String YYYYMM = "yyyyMM";
+
+    private static String YYYY_MM_DD = "yyyy-MM-dd";
+
+    private static String YYYY_MM_DD_HH_MM = "yyyy-MM-dd HH:mm";
+
+
+    private static String YYYYMMDDHHMMSS = "yyyyMMddHHmmss";
+
+    private static String YYYYMMDD_HHMMSSSSS = "yyyyMMdd_HHmmssSSS";
+
+    private static String YYYY_MM_DD_HH_MM_SS = "yyyy-MM-dd HH:mm:ss";
+
+
+    /**
+     * 获取当前月
+     * @return
+     */
+    public static String getMonth(){
+        return format(LocalDateTime.now(), YYYYMM);
+    }
+
+    /**
+     * 获取当前月份的前几个月
+     * @param month
+     * @return
+     */
+    public static String minusMonths(int month){
+        return format(LocalDateTime.now().minusMonths(month), YYYYMM);
+    }
+
+    /**
+     * 获取当前时间戳
+     * @return
+     */
+    public static String getDateTime(){
+        return format(LocalDateTime.now(), YYYYMMDD_HHMMSSSSS);
+    }
+
+
+    /**
+     * 字符串转LocalDateTime
+     * @param time 字符串
+     * @return LocalDateTime
+     */
+    public static LocalDateTime srtToLocalDateTime(String time){
+        return LocalDateTime.parse(time, DateTimeFormatter.ofPattern(YYYY_MM_DD_HH_MM));
+    }
+
+    public static LocalDate srtToLocalDate(String time){
+        return LocalDate.parse(time, DateTimeFormatter.ofPattern(YYYY_MM_DD));
+    }
+
+
+
+    /**
+     * 是否小于当前时间
+     * @param date
+     * @return
+     */
+    public static boolean isBefore(LocalDate date){
+        LocalDateTime localDateTime = date.atTime(LocalTime.of(00,00, 00));
+        return localDateTime.isBefore(LocalDateTime.now());
+
+    }
+
+    /**
+     *
+     * @param date yyyy-MM-dd
+     * @return
+     */
+    public static boolean isBefore(String date){
+        LocalDate localDate = srtToLocalDate(date);
+        return isBefore(localDate);
+
+    }
+
+
+
+    @Test
+    public void test(){
+        System.out.println(srtToLocalDateTime("2022-02-16 12:26"));
+    }
+}

+ 52 - 9
gis_common/src/main/java/com/gis/common/util/FileUtils.java

@@ -1,17 +1,19 @@
 package com.gis.common.util;
 
-import cn.hutool.core.date.DateUtil;
 import cn.hutool.core.io.FileUtil;
+import cn.hutool.core.util.StrUtil;
 import com.gis.common.base.exception.BaseRuntimeException;
 import com.gis.common.constant.ConfigConstant;
 import lombok.extern.slf4j.Slf4j;
-import org.apache.commons.lang3.StringUtils;
+import org.junit.Test;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 import org.springframework.web.multipart.MultipartFile;
 
-import java.time.LocalDateTime;
+import java.io.*;
 import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicInteger;
 
 
 /**
@@ -24,9 +26,11 @@ public class FileUtils {
     @Autowired
     ConfigConstant configConstant;
 
+    // 确保同一时间上传文件的唯一性
+    private static final AtomicInteger ATOMIC_INTEGER = new AtomicInteger();
+
     public boolean checkFile(MultipartFile file) {
         //设置允许上传文件类型
-//        String suffixList = ".jpg,.gif,.png,.ico,.bmp,.jpeg,.zip,.zp,.rar,.mp3,.mp4,.avi,.mov,.4dage,.wav,.wma,.m4a";
         String suffixList = configConstant.serverFileFallow;
         // 获取文件后缀
         if(file == null){
@@ -34,10 +38,11 @@ public class FileUtils {
             return false;
         }
         String fileName = file.getOriginalFilename();
+        log.info("上传文件名称:{}", fileName);
         String suffix = fileName.substring(fileName.lastIndexOf(".")
                 + 1, fileName.length());
         if (suffixList.contains(suffix.trim().toLowerCase())) {
-            log.info("无非法参数可以放行!!!");
+            // log.info("无非法参数可以放行!!!");
             return true;
         }
         log.error("存在非法参数不能放行!请核对上传文件格式,重新刷新页面再次上传!输入文件后缀: {}", suffix);
@@ -49,7 +54,7 @@ public class FileUtils {
      *
      * @param file
      * @param isPinYinRename false:时间戳重命名, true:用拼音重名文件
-     * @param savePath 保存地址,没有文件名
+     * @param savePath 保存地址(前面有斜杠, 后面没有),没有文件名
      * @return 文件名
      */
     public String upload(MultipartFile file, String savePath, boolean isPinYinRename) {
@@ -64,10 +69,10 @@ public class FileUtils {
         String fileName = file.getOriginalFilename();
         String newName;
         if (isPinYinRename){
-             newName = RegexUtil.getPinyinName(fileName);
+            newName = RegexUtil.getPinyinName(fileName);
         } else {
-            String suffix = StringUtils.substringAfterLast(fileName, ".");
-            newName = DateUtil.format(LocalDateTime.now(), "yyyyMMdd_HHmmssSSS") + "." + suffix;
+            String suffix = StrUtil.subAfter(fileName, ".", true);
+            newName =  DateUtils.getDateTime() + ATOMIC_INTEGER.incrementAndGet() + "." + suffix;
         }
 
         savePath = configConstant.serverBasePath + savePath + "/" + newName;
@@ -83,4 +88,42 @@ public class FileUtils {
         return null;
     }
 
+    /**
+     *
+     * @param file
+     * @param isPinYinRename false:时间戳重命名, true:用拼音重名文件
+     * @param savePath 保存地址(前面有斜杠, 后面没有),没有文件名
+     * @return map
+     */
+    public Map<String, Object> uploadMap(MultipartFile file, String savePath, boolean isPinYinRename) {
+        String newName = this.upload(file, savePath, isPinYinRename);
+        HashMap<String, Object> result = new HashMap<>();
+        // 防止名字过长,超过数据库长度
+        String originalFilename = file.getOriginalFilename();
+        if (originalFilename != null && originalFilename.length() > 64){
+            String suffix = StrUtil.subAfter(originalFilename, ".", true);
+            originalFilename = originalFilename.substring(64);
+            originalFilename = originalFilename + "." + suffix;
+        }
+        result.put("fileName", originalFilename);
+        result.put("filePath", savePath + "/" + newName);
+        return result;
+
+    }
+
+    /**
+     * 真删除文件
+     * @param path 参数是相对地址
+     */
+    public void del(String path){
+        if (StrUtil.isBlank(path)){
+            return;
+        }
+        String delPath = configConstant.serverBasePath + path;
+        FileUtil.del(delPath);
+        log.info("真删除文件: {}", delPath);
+    }
+
+
+
 }

+ 57 - 0
gis_scene/pom.xml

@@ -0,0 +1,57 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <parent>
+        <artifactId>scene_zhuhai_partyhistor</artifactId>
+        <groupId>com.gis</groupId>
+        <version>1.0.0</version>
+    </parent>
+
+    <modelVersion>4.0.0</modelVersion>
+    <artifactId>gis_scene</artifactId>
+    <packaging>jar</packaging>
+
+    <dependencies>
+        <dependency>
+            <groupId>com.gis</groupId>
+            <artifactId>gis_common</artifactId>
+        </dependency>
+
+
+        <!-- 针对proto包 转换格式用-->
+        <dependency>
+            <groupId>com.google.protobuf</groupId>
+            <artifactId>protobuf-java</artifactId>
+            <version>3.2.0</version>
+        </dependency>
+        <dependency>
+            <groupId>com.googlecode.protobuf-java-format</groupId>
+            <artifactId>protobuf-java-format</artifactId>
+            <version>1.4</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.codehaus.jackson</groupId>
+            <artifactId>jackson-mapper-asl</artifactId>
+            <version>1.9.11</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.codehaus.jackson</groupId>
+            <artifactId>jackson-smile</artifactId>
+            <version>1.9.12</version>
+        </dependency>
+
+        <dependency>
+            <groupId>com.belerweb</groupId>
+            <artifactId>pinyin4j</artifactId>
+            <version>2.5.1</version>
+        </dependency>
+
+    </dependencies>
+
+
+
+
+
+</project>

+ 98 - 0
gis_scene/src/main/java/com/gis/scene/controller/SceneController.java

@@ -0,0 +1,98 @@
+package com.gis.scene.controller;
+
+import com.gis.common.base.aop.WebControllerLog;
+import com.gis.common.base.entity.dto.PageDto;
+import com.gis.common.util.Result;
+import com.gis.scene.entity.dto.RoamViableDto;
+import com.gis.scene.entity.dto.SceneDataDto;
+import com.gis.scene.entity.po.SceneEntity;
+import com.gis.scene.service.SceneService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+
+import javax.validation.Valid;
+
+
+/**
+ * Created by owen on 2020/5/8 0008 9:54
+ */
+@Slf4j
+@Api(tags = "场景管理")
+@RestController
+@RequestMapping("/cms/scene")
+public class SceneController  {
+
+    @Autowired
+    SceneService sceneService;
+
+
+
+    @ApiOperation("场景列表")
+    @PostMapping("list")
+    public Result<SceneEntity> list(@RequestBody PageDto param) {
+        return sceneService.search(param);
+    }
+
+    @WebControllerLog(description = "场景管理-场景编辑", addDb=true)
+    @ApiOperation("场景编辑")
+    @PostMapping("edit")
+    public Result edit(@Valid @RequestBody SceneDataDto param)  {
+        return sceneService.edit(param);
+    }
+
+    @WebControllerLog(description = "场景管理-场景编辑", addDb=true)
+    @ApiOperation("漫游可行")
+    @PostMapping("roamViable")
+    public Result roamViable(@RequestBody RoamViableDto param) throws Exception {
+        return sceneService.roamViable(param);
+    }
+
+
+    /**
+     * 场景,真删除
+     */
+    @WebControllerLog(description = "场景管理-删除", addDb=true)
+    @ApiOperation("场景删除")
+    @GetMapping("removes/{ids}")
+    public Result removes(@PathVariable String ids) {
+        return sceneService.del(ids);
+    }
+
+
+
+    @ApiOperation("场景详情")
+    @GetMapping("detail/{id}")
+    public Result detail(@PathVariable Long id) {
+        SceneEntity entity = sceneService.getById(id);
+        if (entity == null) {
+            log.error("对象id不存在 : {}", id);
+            return Result.failure("对象id不存在");
+        }
+        return Result.success(entity);
+    }
+
+
+    /**
+     * 只有一个场景是显示状态
+     */
+    @ApiOperation("场景显示")
+    @GetMapping("display/{id}")
+    public Result display(@PathVariable Long id) {
+        return sceneService.display(id);
+    }
+
+
+
+    @ApiOperation(value = "上传到指定场景码目录", notes = "热点-时间戳命名")
+    @PostMapping(value = "upload/{sceneCode}", consumes = {"multipart/form-data"})
+    public Result upload(MultipartFile file , @PathVariable String sceneCode) {
+        return sceneService.upload(file, sceneCode);
+    }
+
+
+
+}

+ 24 - 0
gis_scene/src/main/java/com/gis/scene/entity/dto/RoamViableDto.java

@@ -0,0 +1,24 @@
+package com.gis.scene.entity.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import javax.validation.constraints.NotBlank;
+
+/**
+ * Created by owen on 2020/7/27 0027 16:01
+ *
+ * 漫游可行
+ */
+
+@Data
+public class RoamViableDto {
+
+    @NotBlank(message = "场景码不能为空")
+    @ApiModelProperty(value = "场景码")
+    private String sceneCode;
+
+    @NotBlank(message = "漫游数据不能为空")
+    @ApiModelProperty(value = "漫游数据")
+    private String data;
+}

+ 38 - 0
gis_scene/src/main/java/com/gis/scene/entity/dto/SceneDataDto.java

@@ -0,0 +1,38 @@
+package com.gis.scene.entity.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import javax.validation.constraints.NotBlank;
+
+
+/**
+ * Created by Owen on 2019/10/28 0028 12:24
+ *
+ * 编辑场景使用
+ */
+@Data
+public class SceneDataDto {
+
+//    private String name;
+
+    @NotBlank(message = "场景码不能为空")
+    @ApiModelProperty(value = "场景码", required = true)
+    private String sceneCode;
+
+    /** data2.js */
+    private String hots;
+
+    private String guides;
+
+    /** someData.json model */
+    private String info;
+
+    /** data2.js */
+    private String tourAudio;
+
+    /** data2.js 数组*/
+    private String overlays;
+
+
+}

+ 26 - 0
gis_scene/src/main/java/com/gis/scene/entity/dto/ScenePageDto.java

@@ -0,0 +1,26 @@
+package com.gis.scene.entity.dto;
+
+import com.gis.common.base.entity.dto.PageDto;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import javax.validation.constraints.NotBlank;
+
+
+/**
+ * Created by Owen on 2020/08/18 0028 12:24
+ *
+ *
+ */
+@Data
+public class ScenePageDto extends PageDto {
+
+
+    @NotBlank(message = "类型不能为空")
+    @ApiModelProperty(value = "类型,in:室内, out:室外", required = true)
+    private String type;
+
+
+
+
+}

+ 63 - 0
gis_scene/src/main/java/com/gis/scene/entity/po/SceneEntity.java

@@ -0,0 +1,63 @@
+package com.gis.scene.entity.po;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.gis.common.base.entity.po.BaseEntity;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import javax.persistence.Entity;
+import javax.persistence.Table;
+import java.io.Serializable;
+
+@Data
+@TableName(value = "tb_scene")
+public class SceneEntity extends BaseEntity implements Serializable {
+
+    private static final long serialVersionUID = -8093446477843493946L;
+
+    @ApiModelProperty(value = "场景码")
+    private String sceneCode;
+
+    @ApiModelProperty(value = "存放地址")
+    private String path;
+
+    @ApiModelProperty(value = "场景名称")
+    private String sceneTitle;
+
+//    @ApiModelProperty(value = "场景url")
+//    private String webSite;
+
+//    @ApiModelProperty(value = "简介")
+//    private String description;
+
+//    @ApiModelProperty(value = "提交用户Id")
+//    private Long submitId;
+//
+//    @ApiModelProperty(value = "提交用户名称")
+//    private String submitName;
+//
+//    @ApiModelProperty(value = "审核者Id")
+//    private Long auditId;
+
+//    @ApiModelProperty(value = "状态,1:草稿中,2:待审核,3:审核不通过,4:审核通过")
+//    private Integer status;
+
+//    @ApiModelProperty(value = "原因")
+//    private String reason;
+
+    @ApiModelProperty(value = "是否显示,1:是, 0:否")
+    private Integer display;
+
+//    @ApiModelProperty(value = "类型,in:室内, out:室外")
+//    private String type;
+
+//    @ApiModelProperty(value = "排序")
+//    private Integer sort;
+
+    @ApiModelProperty(value = "浏览量")
+    private Integer visit;
+
+    @ApiModelProperty(value = "点赞量")
+    private Integer star;
+
+}

+ 30 - 0
gis_scene/src/main/java/com/gis/scene/mapper/SceneMapper.java

@@ -0,0 +1,30 @@
+package com.gis.scene.mapper;
+
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.gis.scene.entity.po.SceneEntity;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Select;
+import org.apache.ibatis.annotations.Update;
+import org.springframework.stereotype.Component;
+
+
+@Component
+@Mapper
+public interface SceneMapper extends BaseMapper<SceneEntity> {
+
+    @Select("select * from tb_scene where is_delete=0 and scene_code = #{m}")
+    SceneEntity findBySceneCode(String m);
+
+    @Update("update tb_scene set display = 0 , update_time = NOW() where is_delete=0 and display = 1 ")
+    void setDisable();
+
+    @Update("update tb_scene set display = 1 , update_time = NOW() where is_delete=0 and id = #{id} ")
+    void setDisplay(Long id);
+
+    @Update("update tb_scene set star=star+1 , update_time = NOW() where is_delete=0 and id = #{id} ")
+    void addStar(Long id);
+
+    @Update("update tb_scene set visit=visit+1 , update_time = NOW() where is_delete=0 and id = #{id} ")
+    void addVisit(Long id);
+}

File diff suppressed because it is too large
+ 7340 - 0
gis_scene/src/main/java/com/gis/scene/proto/BigSceneProto.java


File diff suppressed because it is too large
+ 4654 - 0
gis_scene/src/main/java/com/gis/scene/proto/Common.java


File diff suppressed because it is too large
+ 4345 - 0
gis_scene/src/main/java/com/gis/scene/proto/Visionmodeldata.java


+ 37 - 0
gis_scene/src/main/java/com/gis/scene/proto/constant/ConstantCmd.java

@@ -0,0 +1,37 @@
+package com.gis.scene.proto.constant;
+
+public class ConstantCmd {
+
+	  //生成模型的命令
+	  public static final String BUILD_MODEL_COMMAND = "bash /home/ubuntu/bin/Launcher.sh ";
+
+	  // 生成切片图
+	  public static final String SLICE_SKYBOX = "bash /home/ubuntu/bin/Skybox.sh ";
+
+	  // 把obj文件传txt文件
+	  public static final String OBJ_TO_TXT = "bash /home/ubuntu/bin/obj2txt.sh ";
+
+//	  public static final String BUILD_MODEL_SFM_COMMAND = "bash /home/ubuntu/run_sfm.sh ";
+//
+//	  public static final String REBUILD_MODEL_FLLOR = "bash /home/ubuntu/bin/Panoramix_Floorplan.sh ";
+//	  //切图命令
+//	  public static final String CUT_IMG_COMMAND = "bash /home/ubuntu/OpenSfM/bin/run_cube.sh ";
+//	  //调整图片的命令
+//	  public static final String ADJUST_IMG_COMMAND = "/home/ubuntu/OpenSfM/bin/run_skybox ";
+//
+//
+//
+//	  //转台拼图命令
+//	  public static final String BUILD_PANORAMA = "AutopanoGiga /home/ubuntu/data/";
+//	  //六目,拼图,计算,切图(二代)
+//	  public static final String BUILD_FOR_SIX = "bash /home/ubuntu/run_all_m6.sh ";
+//
+//	//合并音频
+//	public static final String MERGE_VIDEO = "bash /monchickey/ffmpeg/bin/ff_synthesis.sh ";
+//
+//	//生成一段静音音频
+//	public static final String CREATE_MUTE_VIDEO = "bash /monchickey/ffmpeg/bin/ff_mtue.sh ";
+//
+//	public static final String OSS_UTIL_CP ="bash /opt/ossutil/oss.sh ";
+
+}

+ 41 - 0
gis_scene/src/main/java/com/gis/scene/proto/constant/ConstantFileName.java

@@ -0,0 +1,41 @@
+package com.gis.scene.proto.constant;
+
+public class ConstantFileName {
+//    //背景音乐
+//    public static final String BACKGROUND_MUSIC = "bg.mp3";
+//    //编辑页面,第二代
+//    public static final String MODEL_DATAFILE = "modeldata.json";
+//    public static final String HOT_DATAFILE = "hot.json";
+//    public static final String MEDIA_DATAFILE = "mediaInfo.json";
+//    public static final String SCREEN_CRP_DATAFILE = "screenCap";
+//    //导览(一代)
+//    public static final String GUIDE_DATAFILE = "tour.json";
+//
+//    //文件夹名称
+//    public static final String GUIDE_MEDIA_FOLDER = "guide";
+//    public static final String HOT_MEDIA_FOLDER = "hot";
+//    public static final String OTHER_MEDIA_FOLDER = "other";
+//
+//    //论坛过滤文档
+//    public static final String BBS_SENSITIVE = "SensitiveWord.txt";
+//    public static final String LOGO_NAME = "logo.jpg";
+//
+//    //app部分
+//    public static final String APP_FOLDER = "appupload";
+//
+//    public static final String FLOOR_LOGO_PIC_NAME = "floorLogoImg.png";
+//
+//    public static final String TOUR_LIST = "tourList.json";
+//    public static final String VOICE_NAME = "201810";
+//    public static final String WECHAT_VOICE_NAME = "wechat";
+//
+//    public static final String TOURLIST_FOLDER = "tour";
+//    //public static final String TEMPFILES = "tempFiles";
+//
+//
+//
+//    public static final String BUCKET_NAME = "4dkankan";
+
+    // 这个码要跟前端一致
+    public static final String modelUUID = "dacf7dfa24ae47fab8fcebfe4dc41ab9";
+}

+ 61 - 0
gis_scene/src/main/java/com/gis/scene/proto/constant/ConstantFilePath.java

@@ -0,0 +1,61 @@
+package com.gis.scene.proto.constant;
+
+public class ConstantFilePath {
+//    public static final String BASE_PATH = "/mnt/4Dkankan";
+//    //论坛上传图片后,服务器存放的地址
+//    public static final String BBS_IMAGES_PATH = "/mnt/4Dkankan/bbs/upload/image/";
+//    // 用户上传图片
+//    public static final String USER_IMAGES_PATH = "/mnt/4Dkankan/user/";
+//    // 图片暂存地址(创建二维码等)
+//    public static final String TEMP_IMAGES_PATH = "/mnt/4Dkankan/temp/upload/image/";
+//    // 场景
+////    public static final String SCENE_PATH = "/mnt/4Dkankan/scene/";
+//
+//    // 代理商
+//    public static final String AGENT_PATH = "/mnt/4Dkankan/agent/";
+//    // 场景二维码
+//    public static final String SCENE_QR_CODE_PATH = "/mnt/4Dkankan/sceneQRcode/";
+//    // excel
+//    public static final String EXCEL_PATH = "/mnt/4Dkankan/excel/";
+//    // medias
+//    public static final String MEDIAS_PATH = "/mnt/4Dkankan/medias/";
+//    // logo
+//    public static final String LOGO_PATH = "/mnt/4Dkankan/logo/";
+//    // login qr code
+//    public static final String LOGIN_QR_CODE_PATH = "/mnt/4Dkankan/login/qrcode/";
+//
+//    public static final String WEIXIN_CERT = "/mnt/home/ubuntu/user/apiclient_cert.p12";
+//
+//    public static final String PREFIX = "/home/user";
+//    public static final String CREATE_MODEL_PATH = PREFIX + "/photo_data/model/";
+//    //大场景
+//    public static final String CREATE_BIG_SCENE_PATH = PREFIX + "/photo_data/bigscene/";
+//    //生成模型的路径
+////    public static final String BUILD_MODEL_PATH = "/mnt/data/";
+//
+//
+//    //支付二维码图片存放路径
+//    public static final String ALI_QRCODE_FOLDER = "/mnt/4Dkankan/alicode/";
+//    public static final String WEIXIN_QRCODE_FOLDER = "/mnt/4Dkankan/weixincode/";
+//
+//    public static final String OSS_PREFIX = "home/";
+
+    //生成模型的路径, 计算模型使用
+//    public static final String BUILD_MODEL_PATH = "/data/kanfang/pano/";
+
+
+    // 123kanfang 保存到阿里云位置, 前面不能有/
+//    public static final String UPLOAD_SCENE_PATH = "4dkktmp/images/images";
+
+    // oss 存放路径
+    public static final String UPLOAD_HOUSE_PATH = "kanfang/house/";
+
+    // oss 算法生成文件存放路径(high: 垂直校验全景图, low: 生成模型缩略图)
+    /**
+     * oss 算法生成文件存放路径(high: 垂直校验全景图, low: 生成模型缩略图)
+     * images/images + d_场景码
+     * 场景码建议9位
+     */
+    public static final String OSS_IMAGE_PATH = "images/images";
+
+}

+ 156 - 0
gis_scene/src/main/java/com/gis/scene/proto/format/CouchDBFormat.java

@@ -0,0 +1,156 @@
+package com.gis.scene.proto.format;
+
+
+import com.google.protobuf.ExtensionRegistry;
+import com.google.protobuf.Message;
+import com.google.protobuf.UnknownFieldSet;
+
+import java.io.IOException;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: aantonov
+ * Date: Mar 16, 2010
+ * Time: 4:06:05 PM
+ * To change this template use File | Settings | File Templates.
+ */
+public class CouchDBFormat extends JsonFormat {
+
+    /**
+     * Outputs a textual representation of the Protocol Message supplied into the parameter output.
+     * (This representation is the new version of the classic "ProtocolPrinter" output from the
+     * original Protocol Buffer system)
+     */
+    public static void print(Message message, Appendable output) throws IOException {
+        CouchDBGenerator generator = new CouchDBGenerator(output);
+        generator.print("{");
+        print(message, generator);
+        generator.print("}");
+    }
+
+    /**
+     * Outputs a textual representation of {@code fields} to {@code output}.
+     */
+    public static void print(UnknownFieldSet fields, Appendable output) throws IOException {
+        CouchDBGenerator generator = new CouchDBGenerator(output);
+        generator.print("{");
+        printUnknownFields(fields, generator);
+        generator.print("}");
+    }
+
+    /**
+     * Like {@code print()}, but writes directly to a {@code String} and returns it.
+     */
+    public static String printToString(Message message) {
+        try {
+            StringBuilder text = new StringBuilder();
+            print(message, text);
+            return text.toString();
+        } catch (IOException e) {
+            throw new RuntimeException("Writing to a StringBuilder threw an IOException (should never happen).",
+                                       e);
+        }
+    }
+
+    /**
+     * Like {@code print()}, but writes directly to a {@code String} and returns it.
+     */
+    public static String printToString(UnknownFieldSet fields) {
+        try {
+            StringBuilder text = new StringBuilder();
+            print(fields, text);
+            return text.toString();
+        } catch (IOException e) {
+            throw new RuntimeException("Writing to a StringBuilder threw an IOException (should never happen).",
+                                       e);
+        }
+    }
+
+    /**
+     * Parse a text-format message from {@code input} and merge the contents into {@code builder}.
+     */
+    public static void merge(Readable input, Message.Builder builder) throws IOException {
+        merge(input, ExtensionRegistry.getEmptyRegistry(), builder);
+    }
+
+    /**
+     * Parse a text-format message from {@code input} and merge the contents into {@code builder}.
+     */
+    public static void merge(CharSequence input, Message.Builder builder) throws ParseException {
+        merge(input, ExtensionRegistry.getEmptyRegistry(), builder);
+    }
+
+    /**
+     * Parse a text-format message from {@code input} and merge the contents into {@code builder}.
+     * Extensions will be recognized if they are registered in {@code extensionRegistry}.
+     */
+    public static void merge(Readable input,
+                             ExtensionRegistry extensionRegistry,
+                             Message.Builder builder) throws IOException {
+        // Read the entire input to a String then parse that.
+
+        // If StreamTokenizer were not quite so crippled, or if there were a kind
+        // of Reader that could read in chunks that match some particular regex,
+        // or if we wanted to write a custom Reader to tokenize our stream, then
+        // we would not have to read to one big String. Alas, none of these is
+        // the case. Oh well.
+
+        merge(toStringBuilder(input), extensionRegistry, builder);
+    }
+
+    /**
+     * Parse a text-format message from {@code input} and merge the contents into {@code builder}.
+     * Extensions will be recognized if they are registered in {@code extensionRegistry}.
+     */
+    public static void merge(CharSequence input,
+                             ExtensionRegistry extensionRegistry,
+                             Message.Builder builder) throws ParseException {
+        Tokenizer tokenizer = new Tokenizer(input);
+
+        // Based on the state machine @ http://json.org/
+
+        tokenizer.consume("{"); // Needs to happen when the object starts.
+        while (!tokenizer.tryConsume("}")) { // Continue till the object is done
+            mergeField(tokenizer, extensionRegistry, builder);
+        }
+    }
+
+    protected static class Tokenizer extends JsonFormat.Tokenizer {
+
+        /**
+         * Construct a tokenizer that parses tokens from the given text.
+         */
+        public Tokenizer(CharSequence text) {
+            super(text);
+        }
+
+        @Override
+        public String consumeIdentifier() throws ParseException {
+            String id = super.consumeIdentifier();
+            if ("_id".equals(id)) {
+                return "id";
+            } else if ("_rev".equals(id)) {
+                return "rev";
+            }
+            return id;
+        }
+    }
+
+    protected static class CouchDBGenerator extends JsonFormat.JsonGenerator {
+
+        public CouchDBGenerator(Appendable output) {
+            super(output);
+        }
+
+        @Override
+        public void print(CharSequence text) throws IOException {
+            if ("id".equals(text)) {
+                super.print("_id");
+            } else if ("rev".equals(text)) {
+                super.print("_rev");
+            } else {
+                super.print(text);
+            }
+        }
+    }
+}

+ 703 - 0
gis_scene/src/main/java/com/gis/scene/proto/format/HtmlFormat.java

@@ -0,0 +1,703 @@
+package com.gis.scene.proto.format;
+/* 
+    Copyright (c) 2009, Orbitz World Wide
+    All rights reserved.
+
+    Redistribution and use in source and binary forms, with or without modification, 
+    are permitted provided that the following conditions are met:
+
+        * Redistributions of source code must retain the above copyright notice, 
+          this list of conditions and the following disclaimer.
+        * Redistributions in binary form must reproduce the above copyright notice, 
+          this list of conditions and the following disclaimer in the documentation 
+          and/or other materials provided with the distribution.
+        * Neither the name of the Orbitz World Wide nor the names of its contributors 
+          may be used to endorse or promote products derived from this software 
+          without specific prior written permission.
+
+    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+    "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+    LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+    A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+    OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+    SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+    LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+    DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+    THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+    (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+    OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+
+import com.google.protobuf.ByteString;
+import com.google.protobuf.Descriptors.EnumValueDescriptor;
+import com.google.protobuf.Descriptors.FieldDescriptor;
+import com.google.protobuf.Message;
+import com.google.protobuf.UnknownFieldSet;
+
+import java.io.IOException;
+import java.math.BigInteger;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+
+/**
+ * Provide ascii html formatting support for proto2 instances.
+ * <p>
+ * (c) 2009-10 Orbitz World Wide. All Rights Reserved.
+ * 
+ * @author eliran.bivas@gmail.com Eliran Bivas
+ * @version $HtmlFormat.java Mar 12, 2009 4:00:33 PM$
+ */
+public final class HtmlFormat {
+
+    private static final String META_CONTENT = "<meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\" />";
+    private static final String MAIN_DIV_STYLE = "color: black; font-size: 14px; font-family: sans-serif; font-weight: bolder; margin-bottom: 10px;";
+    private static final String FIELD_NAME_STYLE = "font-weight: bold; color: #669966;font-size: 14px; font-family: sans-serif;";
+    private static final String FIELD_VALUE_STYLE = "color: #3300FF;font-size: 13px; font-family: sans-serif;";
+
+    /**
+     * Outputs a textual representation of the Protocol Message supplied into the parameter output.
+     * (This representation is the new version of the classic "ProtocolPrinter" output from the
+     * original Protocol Buffer system)
+     */
+    public static void print(Message message, Appendable output) throws IOException {
+        HtmlGenerator generator = new HtmlGenerator(output);
+        printTitle(message, generator);
+        print(message, generator);
+        generator.print("</body></html>");
+    }
+
+    private static void printTitle(final Message message, final HtmlGenerator generator) throws IOException {
+        generator.print("<html><head>");
+        generator.print(META_CONTENT);
+        generator.print("<title>");
+        generator.print(message.getDescriptorForType().getFullName());
+        generator.print("</title></head><body>");
+        generator.print("<div style=\"");
+        generator.print(MAIN_DIV_STYLE);
+        generator.print("\">message : ");
+        generator.print(message.getDescriptorForType().getFullName());
+        generator.print("</div>");
+    }
+
+    /**
+     * Outputs a textual representation of {@code fields} to {@code output}.
+     */
+    public static void print(UnknownFieldSet fields, Appendable output) throws IOException {
+        HtmlGenerator generator = new HtmlGenerator(output);
+        generator.print("<html>");
+        generator.print(META_CONTENT);
+        generator.print("</head><body>");
+        printUnknownFields(fields, generator);
+        generator.print("</body></html>");
+    }
+
+    /**
+     * Like {@code print()}, but writes directly to a {@code String} and returns it.
+     */
+    public static String printToString(Message message) {
+        try {
+            StringBuilder text = new StringBuilder();
+            print(message, text);
+            return text.toString();
+        } catch (IOException e) {
+            throw new RuntimeException("Writing to a StringBuilder threw an IOException (should never happen).",
+                                       e);
+        }
+    }
+
+    /**
+     * Like {@code print()}, but writes directly to a {@code String} and returns it.
+     */
+    public static String printToString(UnknownFieldSet fields) {
+        try {
+            StringBuilder text = new StringBuilder();
+            print(fields, text);
+            return text.toString();
+        } catch (IOException e) {
+            throw new RuntimeException("Writing to a StringBuilder threw an IOException (should never happen).",
+                                       e);
+        }
+    }
+
+    private static void print(Message message, HtmlGenerator generator) throws IOException {
+
+        for (Map.Entry<FieldDescriptor, Object> field : message.getAllFields().entrySet()) {
+            printField(field.getKey(), field.getValue(), generator);
+        }
+        printUnknownFields(message.getUnknownFields(), generator);
+    }
+
+    public static void printField(FieldDescriptor field, Object value, HtmlGenerator generator) throws IOException {
+
+        if (field.isRepeated()) {
+            // Repeated field. Print each element.
+            for (Object element : (List<?>) value) {
+                printSingleField(field, element, generator);
+            }
+        } else {
+            printSingleField(field, value, generator);
+        }
+    }
+
+    private static void printSingleField(FieldDescriptor field,
+                                         Object value,
+                                         HtmlGenerator generator) throws IOException {
+        if (field.isExtension()) {
+            generator.print("[<span style=\"");
+            generator.print(FIELD_NAME_STYLE);
+            generator.print("\">");
+            // We special-case MessageSet elements for compatibility with proto1.
+            if (field.getContainingType().getOptions().getMessageSetWireFormat()
+                            && (field.getType() == FieldDescriptor.Type.MESSAGE) && (field.isOptional())
+                            // object equality
+                            && (field.getExtensionScope() == field.getMessageType())) {
+                generator.print(field.getMessageType().getFullName());
+            } else {
+                generator.print(field.getFullName());
+            }
+            generator.print("</span>]");
+        } else {
+            generator.print("<span style=\"");
+            generator.print(FIELD_NAME_STYLE);
+            generator.print("\">");
+            if (field.getType() == FieldDescriptor.Type.GROUP) {
+                // Groups must be serialized with their original capitalization.
+                generator.print(field.getMessageType().getName());
+            } else {
+                generator.print(field.getName());
+            }
+            generator.print("</span>");
+        }
+
+        if (field.getJavaType() == FieldDescriptor.JavaType.MESSAGE) {
+            generator.print(" <span style=\"color: red;\">{</span><br/>");
+            generator.indent();
+        } else {
+            generator.print(": ");
+        }
+
+        printFieldValue(field, value, generator);
+
+        if (field.getJavaType() == FieldDescriptor.JavaType.MESSAGE) {
+            generator.outdent();
+            generator.print("<span style=\"color: red;\">}</span>");
+        }
+        generator.print("<br/>");
+    }
+
+    private static void printFieldValue(FieldDescriptor field, Object value, HtmlGenerator generator) throws IOException {
+        generator.print("<span style=\"");
+        generator.print(FIELD_VALUE_STYLE);
+        generator.print("\">");
+        switch (field.getType()) {
+            case INT32:
+            case INT64:
+            case SINT32:
+            case SINT64:
+            case SFIXED32:
+            case SFIXED64:
+            case FLOAT:
+            case DOUBLE:
+            case BOOL:
+                // Good old toString() does what we want for these types.
+                generator.print(value.toString());
+                break;
+
+            case UINT32:
+            case FIXED32:
+                generator.print(unsignedToString((Integer) value));
+                break;
+
+            case UINT64:
+            case FIXED64:
+                generator.print(unsignedToString((Long) value));
+                break;
+
+            case STRING:
+                generator.print("\"");
+                generator.print(value.toString());
+                generator.print("\"");
+                break;
+
+            case BYTES: {
+                generator.print("\"");
+                generator.print(escapeBytes((ByteString) value));
+                generator.print("\"");
+                break;
+            }
+
+            case ENUM: {
+                generator.print(((EnumValueDescriptor) value).getName());
+                break;
+            }
+
+            case MESSAGE:
+            case GROUP:
+                print((Message) value, generator);
+                break;
+        }
+        generator.print("</span>");
+    }
+
+    private static void printUnknownFields(UnknownFieldSet unknownFields, HtmlGenerator generator) throws IOException {
+        for (Map.Entry<Integer, UnknownFieldSet.Field> entry : unknownFields.asMap().entrySet()) {
+            UnknownFieldSet.Field field = entry.getValue();
+
+            for (long value : field.getVarintList()) {
+                generator.print(entry.getKey().toString());
+                generator.print(": ");
+                generator.print(unsignedToString(value));
+                generator.print("<br/>");
+            }
+            for (int value : field.getFixed32List()) {
+                generator.print(entry.getKey().toString());
+                generator.print(": ");
+                generator.print(String.format((Locale) null, "0x%08x", value));
+                generator.print("<br/>");
+            }
+            for (long value : field.getFixed64List()) {
+                generator.print(entry.getKey().toString());
+                generator.print(": ");
+                generator.print(String.format((Locale) null, "0x%016x", value));
+                generator.print("<br/>");
+            }
+            for (ByteString value : field.getLengthDelimitedList()) {
+                generator.print(entry.getKey().toString());
+                generator.print(": \"");
+                generator.print(escapeBytes(value));
+                generator.print("\"<br/>");
+            }
+            for (UnknownFieldSet value : field.getGroupList()) {
+                generator.print(entry.getKey().toString());
+                generator.print(" <span style=\"color: red;\">{</span><br/>");
+                generator.indent();
+                printUnknownFields(value, generator);
+                generator.outdent();
+                generator.print("<span style=\"color: red;\">}</span><br/>");
+            }
+        }
+    }
+
+    /**
+     * Convert an unsigned 32-bit integer to a string.
+     */
+    private static String unsignedToString(int value) {
+        if (value >= 0) {
+            return Integer.toString(value);
+        } else {
+            return Long.toString((value) & 0x00000000FFFFFFFFL);
+        }
+    }
+
+    /**
+     * Convert an unsigned 64-bit integer to a string.
+     */
+    private static String unsignedToString(long value) {
+        if (value >= 0) {
+            return Long.toString(value);
+        } else {
+            // Pull off the most-significant bit so that BigInteger doesn't think
+            // the number is negative, then set it again using setBit().
+            return BigInteger.valueOf(value & 0x7FFFFFFFFFFFFFFFL).setBit(63).toString();
+        }
+    }
+
+    /**
+     * An inner class for writing text to the output stream.
+     */
+    static private final class HtmlGenerator {
+
+        Appendable output;
+        boolean atStartOfLine = true;
+
+        public HtmlGenerator(Appendable output) {
+            this.output = output;
+        }
+
+        /**
+         * Indent text by two spaces. After calling Indent(), two spaces will be inserted at the
+         * beginning of each line of text. Indent() may be called multiple times to produce deeper
+         * indents.
+         * 
+         * @throws IOException
+         */
+        public void indent() throws IOException {
+            print("<div style=\"margin-left: 25px\">");
+        }
+
+        /**
+         * Reduces the current indent level by two spaces, or crashes if the indent level is zero.
+         * 
+         * @throws IOException
+         */
+        public void outdent() throws IOException {
+            print("</div>");
+        }
+
+        /**
+         * Print text to the output stream.
+         */
+        public void print(CharSequence text) throws IOException {
+            int size = text.length();
+            int pos = 0;
+
+            for (int i = 0; i < size; i++) {
+                if (text.charAt(i) == '\n') {
+                    write("<br/>", i - pos + 1);
+                    pos = i + 1;
+                    atStartOfLine = true;
+                }
+            }
+            write(text.subSequence(pos, size), size - pos);
+        }
+
+        private void write(CharSequence data, int size) throws IOException {
+            if (size == 0) {
+                return;
+            }
+            if (atStartOfLine) {
+                atStartOfLine = false;
+            }
+            output.append(data);
+        }
+    }
+
+    // =================================================================
+    // Utility functions
+    //
+    // Some of these methods are package-private because Descriptors.java uses
+    // them.
+
+    /**
+     * Escapes bytes in the format used in protocol buffer text format, which is the same as the
+     * format used for C string literals. All bytes that are not printable 7-bit ASCII characters
+     * are escaped, as well as backslash, single-quote, and double-quote characters. Characters for
+     * which no defined short-hand escape sequence is defined will be escaped using 3-digit octal
+     * sequences.
+     */
+    static String escapeBytes(ByteString input) {
+        StringBuilder builder = new StringBuilder(input.size());
+        for (int i = 0; i < input.size(); i++) {
+            byte b = input.byteAt(i);
+            switch (b) {
+                // Java does not recognize \a or \v, apparently.
+                case 0x07:
+                    builder.append("\\a");
+                    break;
+                case '\b':
+                    builder.append("\\b");
+                    break;
+                case '\f':
+                    builder.append("\\f");
+                    break;
+                case '\n':
+                    builder.append("\\n");
+                    break;
+                case '\r':
+                    builder.append("\\r");
+                    break;
+                case '\t':
+                    builder.append("\\t");
+                    break;
+                case 0x0b:
+                    builder.append("\\v");
+                    break;
+                case '\\':
+                    builder.append("\\\\");
+                    break;
+                case '\'':
+                    builder.append("\\\'");
+                    break;
+                case '"':
+                    builder.append("\\\"");
+                    break;
+                default:
+                    if (b >= 0x20) {
+                        builder.append((char) b);
+                    } else {
+                        builder.append('\\');
+                        builder.append((char) ('0' + ((b >>> 6) & 3)));
+                        builder.append((char) ('0' + ((b >>> 3) & 7)));
+                        builder.append((char) ('0' + (b & 7)));
+                    }
+                    break;
+            }
+        }
+        return builder.toString();
+    }
+
+    /**
+     * Un-escape a byte sequence as escaped using
+     * {@link #escapeBytes(com.googlecode.protobuf.format.ByteString)}. Two-digit hex escapes (starting with
+     * "\x") are also recognized.
+     */
+    static ByteString unescapeBytes(CharSequence input) throws InvalidEscapeSequence {
+        byte[] result = new byte[input.length()];
+        int pos = 0;
+        for (int i = 0; i < input.length(); i++) {
+            char c = input.charAt(i);
+            if (c == '\\') {
+                if (i + 1 < input.length()) {
+                    ++i;
+                    c = input.charAt(i);
+                    if (isOctal(c)) {
+                        // Octal escape.
+                        int code = digitValue(c);
+                        if ((i + 1 < input.length()) && isOctal(input.charAt(i + 1))) {
+                            ++i;
+                            code = code * 8 + digitValue(input.charAt(i));
+                        }
+                        if ((i + 1 < input.length()) && isOctal(input.charAt(i + 1))) {
+                            ++i;
+                            code = code * 8 + digitValue(input.charAt(i));
+                        }
+                        result[pos++] = (byte) code;
+                    } else {
+                        switch (c) {
+                            case 'a':
+                                result[pos++] = 0x07;
+                                break;
+                            case 'b':
+                                result[pos++] = '\b';
+                                break;
+                            case 'f':
+                                result[pos++] = '\f';
+                                break;
+                            case 'n':
+                                result[pos++] = '\n';
+                                break;
+                            case 'r':
+                                result[pos++] = '\r';
+                                break;
+                            case 't':
+                                result[pos++] = '\t';
+                                break;
+                            case 'v':
+                                result[pos++] = 0x0b;
+                                break;
+                            case '\\':
+                                result[pos++] = '\\';
+                                break;
+                            case '\'':
+                                result[pos++] = '\'';
+                                break;
+                            case '"':
+                                result[pos++] = '\"';
+                                break;
+
+                            case 'x':
+                                // hex escape
+                                int code = 0;
+                                if ((i + 1 < input.length()) && isHex(input.charAt(i + 1))) {
+                                    ++i;
+                                    code = digitValue(input.charAt(i));
+                                } else {
+                                    throw new InvalidEscapeSequence("Invalid escape sequence: '\\x' with no digits");
+                                }
+                                if ((i + 1 < input.length()) && isHex(input.charAt(i + 1))) {
+                                    ++i;
+                                    code = code * 16 + digitValue(input.charAt(i));
+                                }
+                                result[pos++] = (byte) code;
+                                break;
+
+                            default:
+                                throw new InvalidEscapeSequence("Invalid escape sequence: '\\" + c
+                                                                + "'");
+                        }
+                    }
+                } else {
+                    throw new InvalidEscapeSequence("Invalid escape sequence: '\\' at end of string.");
+                }
+            } else {
+                result[pos++] = (byte) c;
+            }
+        }
+
+        return ByteString.copyFrom(result, 0, pos);
+    }
+
+    /**
+     * Thrown by {@link JsonFormat#unescapeBytes} and {@link JsonFormat#unescapeText} when an
+     * invalid escape sequence is seen.
+     */
+    static class InvalidEscapeSequence extends IOException {
+
+        private static final long serialVersionUID = 1L;
+
+        public InvalidEscapeSequence(String description) {
+            super(description);
+        }
+    }
+
+    /**
+     * Like {@link #escapeBytes(com.googlecode.protobuf.format.ByteString)}, but escapes a text string.
+     * Non-ASCII characters are first encoded as UTF-8, then each byte is escaped individually as a
+     * 3-digit octal escape. Yes, it's weird.
+     */
+    static String escapeText(String input) {
+        return escapeBytes(ByteString.copyFromUtf8(input));
+    }
+
+    /**
+     * Un-escape a text string as escaped using {@link #escapeText(String)}. Two-digit hex escapes
+     * (starting with "\x") are also recognized.
+     */
+    static String unescapeText(String input) throws InvalidEscapeSequence {
+        return unescapeBytes(input).toStringUtf8();
+    }
+
+    /**
+     * Is this an octal digit?
+     */
+    private static boolean isOctal(char c) {
+        return ('0' <= c) && (c <= '7');
+    }
+
+    /**
+     * Is this a hex digit?
+     */
+    private static boolean isHex(char c) {
+        return (('0' <= c) && (c <= '9')) || (('a' <= c) && (c <= 'f'))
+        || (('A' <= c) && (c <= 'F'));
+    }
+
+    /**
+     * Interpret a character as a digit (in any base up to 36) and return the numeric value. This is
+     * like {@code Character.digit()} but we don't accept non-ASCII digits.
+     */
+    private static int digitValue(char c) {
+        if (('0' <= c) && (c <= '9')) {
+            return c - '0';
+        } else if (('a' <= c) && (c <= 'z')) {
+            return c - 'a' + 10;
+        } else {
+            return c - 'A' + 10;
+        }
+    }
+
+    /**
+     * Parse a 32-bit signed integer from the text. Unlike the Java standard {@code
+     * Integer.parseInt()}, this function recognizes the prefixes "0x" and "0" to signify
+     * hexidecimal and octal numbers, respectively.
+     */
+    static int parseInt32(String text) throws NumberFormatException {
+        return (int) parseInteger(text, true, false);
+    }
+
+    /**
+     * Parse a 32-bit unsigned integer from the text. Unlike the Java standard {@code
+     * Integer.parseInt()}, this function recognizes the prefixes "0x" and "0" to signify
+     * hexidecimal and octal numbers, respectively. The result is coerced to a (signed) {@code int}
+     * when returned since Java has no unsigned integer type.
+     */
+    static int parseUInt32(String text) throws NumberFormatException {
+        return (int) parseInteger(text, false, false);
+    }
+
+    /**
+     * Parse a 64-bit signed integer from the text. Unlike the Java standard {@code
+     * Integer.parseInt()}, this function recognizes the prefixes "0x" and "0" to signify
+     * hexidecimal and octal numbers, respectively.
+     */
+    static long parseInt64(String text) throws NumberFormatException {
+        return parseInteger(text, true, true);
+    }
+
+    /**
+     * Parse a 64-bit unsigned integer from the text. Unlike the Java standard {@code
+     * Integer.parseInt()}, this function recognizes the prefixes "0x" and "0" to signify
+     * hexidecimal and octal numbers, respectively. The result is coerced to a (signed) {@code long}
+     * when returned since Java has no unsigned long type.
+     */
+    static long parseUInt64(String text) throws NumberFormatException {
+        return parseInteger(text, false, true);
+    }
+
+    private static long parseInteger(String text, boolean isSigned, boolean isLong) throws NumberFormatException {
+        int pos = 0;
+
+        boolean negative = false;
+        if (text.startsWith("-", pos)) {
+            if (!isSigned) {
+                throw new NumberFormatException("Number must be positive: " + text);
+            }
+            ++pos;
+            negative = true;
+        }
+
+        int radix = 10;
+        if (text.startsWith("0x", pos)) {
+            pos += 2;
+            radix = 16;
+        } else if (text.startsWith("0", pos)) {
+            radix = 8;
+        }
+
+        String numberText = text.substring(pos);
+
+        long result = 0;
+        if (numberText.length() < 16) {
+            // Can safely assume no overflow.
+            result = Long.parseLong(numberText, radix);
+            if (negative) {
+                result = -result;
+            }
+
+            // Check bounds.
+            // No need to check for 64-bit numbers since they'd have to be 16 chars
+            // or longer to overflow.
+            if (!isLong) {
+                if (isSigned) {
+                    if ((result > Integer.MAX_VALUE) || (result < Integer.MIN_VALUE)) {
+                        throw new NumberFormatException("Number out of range for 32-bit signed integer: "
+                                                        + text);
+                    }
+                } else {
+                    if ((result >= (1L << 32)) || (result < 0)) {
+                        throw new NumberFormatException("Number out of range for 32-bit unsigned integer: "
+                                                        + text);
+                    }
+                }
+            }
+        } else {
+            BigInteger bigValue = new BigInteger(numberText, radix);
+            if (negative) {
+                bigValue = bigValue.negate();
+            }
+
+            // Check bounds.
+            if (!isLong) {
+                if (isSigned) {
+                    if (bigValue.bitLength() > 31) {
+                        throw new NumberFormatException("Number out of range for 32-bit signed integer: "
+                                                        + text);
+                    }
+                } else {
+                    if (bigValue.bitLength() > 32) {
+                        throw new NumberFormatException("Number out of range for 32-bit unsigned integer: "
+                                                        + text);
+                    }
+                }
+            } else {
+                if (isSigned) {
+                    if (bigValue.bitLength() > 63) {
+                        throw new NumberFormatException("Number out of range for 64-bit signed integer: "
+                                                        + text);
+                    }
+                } else {
+                    if (bigValue.bitLength() > 64) {
+                        throw new NumberFormatException("Number out of range for 64-bit unsigned integer: "
+                                                        + text);
+                    }
+                }
+            }
+
+            result = bigValue.longValue();
+        }
+
+        return result;
+    }
+}

File diff suppressed because it is too large
+ 1338 - 0
gis_scene/src/main/java/com/gis/scene/proto/format/JavaPropsFormat.java


File diff suppressed because it is too large
+ 1603 - 0
gis_scene/src/main/java/com/gis/scene/proto/format/JsonFormat.java


+ 602 - 0
gis_scene/src/main/java/com/gis/scene/proto/format/SmileFormat.java

@@ -0,0 +1,602 @@
+package com.gis.scene.proto.format;
+/* 
+	Copyright (c) 2009, Orbitz World Wide
+	All rights reserved.
+
+	Redistribution and use in source and binary forms, with or without modification, 
+	are permitted provided that the following conditions are met:
+
+		* Redistributions of source code must retain the above copyright notice, 
+		  this list of conditions and the following disclaimer.
+		* Redistributions in binary form must reproduce the above copyright notice, 
+		  this list of conditions and the following disclaimer in the documentation 
+		  and/or other materials provided with the distribution.
+		* Neither the name of the Orbitz World Wide nor the names of its contributors 
+		  may be used to endorse or promote products derived from this software 
+		  without specific prior written permission.
+
+	THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+	"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+	LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+	A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+	OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+	SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+	LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+	DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+	THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+	(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+	OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+
+import com.google.protobuf.*;
+import com.google.protobuf.Descriptors.Descriptor;
+import com.google.protobuf.Descriptors.EnumDescriptor;
+import com.google.protobuf.Descriptors.EnumValueDescriptor;
+import com.google.protobuf.Descriptors.FieldDescriptor;
+import org.codehaus.jackson.JsonGenerator;
+import org.codehaus.jackson.JsonParseException;
+import org.codehaus.jackson.JsonParser;
+import org.codehaus.jackson.JsonToken;
+import org.codehaus.jackson.smile.SmileFactory;
+import org.codehaus.jackson.smile.SmileGenerator;
+import org.codehaus.jackson.smile.SmileParser;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.math.BigInteger;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.regex.Pattern;
+
+/**
+ * Provide ascii text parsing and formatting support for proto2 instances. The implementation
+ * largely follows google/protobuf/text_format.cc.
+ * <p>
+ * (c) 2011 Neustar, Inc. All Rights Reserved.
+ *
+ * @author jeffrey.damick@neustar.biz Jeffrey Damick
+ *         Based on the original code by:
+ * @author eliran.bivas@gmail.com Eliran Bivas
+ * @author aantonov@orbitz.com Alex Antonov
+ *         <p/>
+ * @author wenboz@google.com Wenbo Zhu
+ * @author kenton@google.com Kenton Varda
+ */
+public class SmileFormat {
+    private static SmileFactory smileFactory = new SmileFactory();
+	
+		
+    /**
+     * Outputs a Smile representation of the Protocol Message supplied into the parameter output.
+     * (This representation is the new version of the classic "ProtocolPrinter" output from the
+     * original Protocol Buffer system)
+     */
+    public static void print(Message message, OutputStream output) throws IOException {
+        JsonGenerator generator = createGenerator(output);
+    	print(message, generator);
+    	generator.close();
+    }
+    
+    /**
+     * Outputs a Smile representation of the Protocol Message supplied into the parameter output.
+     * (This representation is the new version of the classic "ProtocolPrinter" output from the
+     * original Protocol Buffer system)
+     */
+    public static void print(Message message, JsonGenerator generator) throws IOException {
+    	generator.writeStartObject();
+    	printMessage(message, generator);
+        generator.writeEndObject();
+        generator.flush();
+    }
+
+    /**
+     * Outputs a Smile representation of {@code fields} to {@code output}.
+     */
+    public static void print(UnknownFieldSet fields, OutputStream output) throws IOException {
+    	JsonGenerator generator = createGenerator(output);
+    	generator.writeStartObject();
+    	printUnknownFields(fields, generator);
+        generator.writeEndObject();
+        generator.close();
+    }
+    
+    
+    
+    /**
+     * Parse a text-format message from {@code input} and merge the contents into {@code builder}.
+     */
+    public static void merge(InputStream input, Message.Builder builder) throws IOException {
+        merge(input, ExtensionRegistry.getEmptyRegistry(), builder);
+    }
+
+        
+    /**
+     * Parse a text-format message from {@code input} and merge the contents into {@code builder}.
+     * Extensions will be recognized if they are registered in {@code extensionRegistry}.
+     * @throws IOException 
+     */
+    public static void merge(InputStream input,
+                             ExtensionRegistry extensionRegistry,
+                             Message.Builder builder) throws IOException {
+    	
+    	SmileParser parser = smileFactory.createJsonParser(input); 
+    	merge(parser, extensionRegistry, builder);
+    }
+    
+    /**
+     * Parse a text-format message from {@code input} and merge the contents into {@code builder}.
+     * Extensions will be recognized if they are registered in {@code extensionRegistry}.
+     * @throws IOException 
+     */
+    public static void merge(JsonParser parser,                 
+    						 ExtensionRegistry extensionRegistry,
+                             Message.Builder builder) throws IOException {
+    	
+        JsonToken token = parser.nextToken();
+        if (token.equals(JsonToken.START_OBJECT)) {
+        	token = parser.nextToken();
+        }
+        while (token != null && !token.equals(JsonToken.END_OBJECT)) {
+        	mergeField(parser, extensionRegistry, builder);
+        	token = parser.nextToken();
+        }
+        
+        // Test to make sure the tokenizer has reached the end of the stream.
+        if (parser.nextToken() != null) {
+            throw new RuntimeException("Expecting the end of the stream, but there seems to be more data!  Check the input for a valid JSON format.");
+        }
+    }
+    
+    
+    
+    protected static JsonGenerator createGenerator(OutputStream output) throws IOException {
+    	SmileGenerator generator = smileFactory.createJsonGenerator(output);
+    	generator.enable(SmileGenerator.Feature.WRITE_HEADER);
+    	generator.enable(SmileGenerator.Feature.WRITE_END_MARKER);
+    	return generator;
+    }
+
+    
+    protected static void printMessage(Message message, JsonGenerator generator) throws IOException {
+
+        for (Iterator<Map.Entry<FieldDescriptor, Object>> iter = message.getAllFields().entrySet().iterator(); iter.hasNext();) {
+            Map.Entry<FieldDescriptor, Object> field = iter.next();
+            printField(field.getKey(), field.getValue(), generator);
+        }
+        printUnknownFields(message.getUnknownFields(), generator);
+    }
+
+    public static void printField(FieldDescriptor field, Object value, JsonGenerator generator) throws IOException {
+
+        printSingleField(field, value, generator);
+    }
+
+    private static void printSingleField(FieldDescriptor field,
+                                         Object value,
+                                         JsonGenerator generator) throws IOException {
+        if (field.isExtension()) {
+            // We special-case MessageSet elements for compatibility with proto1.
+            if (field.getContainingType().getOptions().getMessageSetWireFormat()
+                && (field.getType() == FieldDescriptor.Type.MESSAGE) && (field.isOptional())
+                // object equality
+                && (field.getExtensionScope() == field.getMessageType())) {
+                generator.writeFieldName(field.getMessageType().getFullName());
+            } else {
+            	// extensions will have '.' in them, while normal fields wont..
+            	generator.writeFieldName(field.getFullName());
+            }
+        } else {
+            if (field.getType() == FieldDescriptor.Type.GROUP) {
+                // Groups must be serialized with their original capitalization.
+                generator.writeFieldName(field.getMessageType().getName());
+            } else {
+                generator.writeFieldName(field.getName());
+            }
+        }
+
+        // Done with the name, on to the value
+        if (field.isRepeated()) {
+            // Repeated field. Print each element.
+            generator.writeStartArray();
+            for (Iterator<?> iter = ((List<?>) value).iterator(); iter.hasNext();) {
+                printFieldValue(field, iter.next(), generator);
+            }
+            generator.writeEndArray();
+        } else {
+            printFieldValue(field, value, generator);
+        }
+    }
+
+    private static void printFieldValue(FieldDescriptor field, Object value, JsonGenerator generator) throws IOException {
+    	// TODO: look at using field.getType().getJavaType(), to simplify this..
+    	switch (field.getType()) {
+            case INT32:
+            case SINT32:
+            case SFIXED32:
+            	generator.writeNumber((Integer)value);
+            	break;
+            
+            case INT64:
+            case SINT64:
+            case SFIXED64:
+            	generator.writeNumber((Long)value);
+            	break;
+            	
+            case FLOAT:
+            	generator.writeNumber((Float)value);
+            	break;
+            	
+            case DOUBLE:
+            	generator.writeNumber((Double)value);
+            	break;
+            	
+            case BOOL:
+                // Good old toString() does what we want for these types.
+                generator.writeBoolean((Boolean)value);
+                break;
+
+            case UINT32:
+            case FIXED32:
+                generator.writeNumber(unsignedInt((Integer) value));
+                break;
+
+            case UINT64:
+            case FIXED64:
+                generator.writeNumber(unsignedLong((Long) value));
+                break;
+
+            case STRING:
+            	generator.writeString((String) value);
+                break;
+
+            case BYTES: {
+            	// Here we break with JsonFormat - since there is an issue with non-utf8 bytes..
+            	generator.writeBinary(((ByteString)value).toByteArray());
+                break;
+            }
+
+            case ENUM: {
+            	generator.writeString(((EnumValueDescriptor) value).getName());
+                break;
+            }
+
+            case MESSAGE:
+            case GROUP:
+            	generator.writeStartObject();
+                printMessage((Message) value, generator);
+                generator.writeEndObject();
+                break;
+        }
+    }
+
+    protected static void printUnknownFields(UnknownFieldSet unknownFields, JsonGenerator generator) throws IOException {
+        for (Map.Entry<Integer, UnknownFieldSet.Field> entry : unknownFields.asMap().entrySet()) {
+            UnknownFieldSet.Field field = entry.getValue();
+            
+            generator.writeArrayFieldStart(entry.getKey().toString());
+            for (long value : field.getVarintList()) {
+                generator.writeNumber(value);
+            }
+            for (int value : field.getFixed32List()) {
+                generator.writeNumber(value);
+            }
+            for (long value : field.getFixed64List()) {
+                generator.writeNumber(value);
+            }
+            for (ByteString value : field.getLengthDelimitedList()) {
+            	// here we break with the JsonFormat to support non-utf8 bytes
+            	generator.writeBinary(value.toByteArray());
+            }
+            for (UnknownFieldSet value : field.getGroupList()) {
+                generator.writeStartObject();
+                printUnknownFields(value, generator);
+                generator.writeEndObject();
+            }
+            generator.writeEndArray();
+        }
+    }
+
+
+
+    // =================================================================
+    // Parsing
+   
+    private static final Pattern DIGITS = Pattern.compile(
+          "[0-9]",
+          Pattern.CASE_INSENSITIVE);
+
+    /**
+     * Parse a single field from {@code parser} and merge it into {@code builder}. If a ',' is
+     * detected after the field ends, the next field will be parsed automatically
+     * @throws IOException 
+     * @throws JsonParseException 
+     */
+    protected static void mergeField(JsonParser parser,
+                                   ExtensionRegistry extensionRegistry,
+                                   Message.Builder builder) throws JsonParseException, IOException {
+        FieldDescriptor field = null;
+        Descriptor type = builder.getDescriptorForType();
+        boolean unknown = false;
+        ExtensionRegistry.ExtensionInfo extension = null;
+        JsonToken token = parser.getCurrentToken();
+
+        if (token != null) {
+            String name = parser.getCurrentName();
+            
+            if (name.contains(".")) {
+            	// should be an extension
+            	extension = extensionRegistry.findExtensionByName(name);
+                if (extension == null) {
+                    throw new RuntimeException("Extension \""
+                    		+ name + "\" not found in the ExtensionRegistry.");
+                } else if (extension.descriptor.getContainingType() != type) {
+                    throw new RuntimeException("Extension \"" + name
+                    		+ "\" does not extend message type \""
+                    		+ type.getFullName() + "\".");
+                }
+
+            	field = extension.descriptor;
+            } else {
+            	field = type.findFieldByName(name);
+            }
+
+            // Group names are expected to be capitalized as they appear in the
+            // .proto file, which actually matches their type names, not their field
+            // names.
+            if (field == null) {
+                // Explicitly specify US locale so that this code does not break when
+                // executing in Turkey.
+                String lowerName = name.toLowerCase(Locale.US);
+                field = type.findFieldByName(lowerName);
+                // If the case-insensitive match worked but the field is NOT a group,
+                if ((field != null) && (field.getType() != FieldDescriptor.Type.GROUP)) {
+                    field = null;
+                }
+            }
+            // Again, special-case group names as described above.
+            if ((field != null) && (field.getType() == FieldDescriptor.Type.GROUP)
+                && !field.getMessageType().getName().equals(name)
+                && !field.getMessageType().getFullName().equalsIgnoreCase(name) /* extension */) {
+                field = null;
+            }
+
+            // Last try to lookup by field-index if 'name' is numeric,
+            // which indicates a possible unknown field
+            if (field == null && DIGITS.matcher(name).matches()) {
+                field = type.findFieldByNumber(Integer.parseInt(name));
+                unknown = true;
+            }
+
+            // no throwing exceptions if field not found, since it could be a different version.
+            if (field == null) {
+            	UnknownFieldSet.Builder unknownsBuilder = UnknownFieldSet.newBuilder();
+            	handleMissingField(name, parser, extensionRegistry, unknownsBuilder);
+            	builder.setUnknownFields(unknownsBuilder.build());
+            }
+        }
+
+        if (field != null) {
+        	token = parser.nextToken();
+        	
+            boolean array = token.equals(JsonToken.START_ARRAY);
+
+            if (array) {
+            	token = parser.nextToken();
+                while (!token.equals(JsonToken.END_ARRAY)) {
+                    handleValue(parser, extensionRegistry, builder, field, extension, unknown);
+                    token = parser.nextToken();
+                }
+            } else {
+                handleValue(parser, extensionRegistry, builder, field, extension, unknown);
+            }
+        }
+    }
+
+    private static void handleMissingField(String fieldName, JsonParser parser,
+                                           ExtensionRegistry extensionRegistry,
+                                           UnknownFieldSet.Builder builder) throws IOException {
+    	
+        JsonToken token = parser.nextToken();
+        if (token.equals(JsonToken.START_OBJECT)) {
+            // Message structure
+        	token = parser.nextToken(); // skip name
+        	while (token != null && !token.equals(JsonToken.END_OBJECT)) {
+                handleMissingField(fieldName, parser, extensionRegistry, builder);
+                token = parser.nextToken(); // get } or field name
+            }
+        } else if (token.equals(JsonToken.START_ARRAY)) {
+            // Collection
+            do {
+                handleMissingField(fieldName, parser, extensionRegistry, builder);
+                token = parser.getCurrentToken(); // got value or ]
+            } while (token != null && !token.equals(JsonToken.END_ARRAY));
+        } else {
+            // Primitive value
+        	// NULL, INT, BOOL, STRING
+        	// nothing to do..
+        }
+    }
+
+    private static void handleValue(JsonParser parser,
+                                    ExtensionRegistry extensionRegistry,
+                                    Message.Builder builder,
+                                    FieldDescriptor field,
+                                    ExtensionRegistry.ExtensionInfo extension,
+                                    boolean unknown) throws IOException {
+
+        Object value = null;
+        if (field.getJavaType() == FieldDescriptor.JavaType.MESSAGE) {
+            value = handleObject(parser, extensionRegistry, builder, field, extension, unknown);
+        } else {
+            value = handlePrimitive(parser, field);
+        }
+        if (value != null) {
+            if (field.isRepeated()) {
+                builder.addRepeatedField(field, value);
+            } else {
+                builder.setField(field, value);
+            }
+        }
+    }
+
+    private static Object handlePrimitive(JsonParser parser, FieldDescriptor field) throws IOException {
+        Object value = null;
+        
+        JsonToken token = parser.getCurrentToken();
+        
+        if (token.equals(JsonToken.VALUE_NULL)) {
+            return value;
+        }
+        
+        switch (field.getType()) {
+            case INT32:
+            case SINT32:
+            case SFIXED32:
+            	value = parser.getIntValue();
+                break;
+
+            case INT64:
+            case SINT64:
+            case SFIXED64:
+            	value = parser.getLongValue();
+                break;
+
+            case UINT32:
+            case FIXED32:
+            	int valueInt = parser.getIntValue();
+            	if (valueInt < 0) {
+            		throw new NumberFormatException("Number must be positive: " + valueInt);
+            	}
+            	value = valueInt;
+                break;
+
+            case UINT64:
+            case FIXED64:
+            	long valueLong = parser.getLongValue();
+            	if (valueLong < 0) {
+            		throw new NumberFormatException("Number must be positive: " + valueLong);
+            	}
+            	value = valueLong;
+                break;
+
+            case FLOAT:
+            	value = parser.getFloatValue();
+                break;
+
+            case DOUBLE:
+            	value = parser.getDoubleValue();
+                break;
+
+            case BOOL:
+            	value = parser.getBooleanValue();
+                break;
+
+            case STRING:
+            	value = parser.getText();
+                break;
+
+            case BYTES:
+            	value = ByteString.copyFrom(parser.getBinaryValue());
+                break;
+
+            case ENUM: {
+                EnumDescriptor enumType = field.getEnumType();
+                if (token.equals(JsonToken.VALUE_NUMBER_INT)) {
+                    int number = parser.getIntValue();
+                    value = enumType.findValueByNumber(number);
+                    if (value == null) {
+                        throw new RuntimeException("Enum type \""
+                        		+ enumType.getFullName()
+                        		+ "\" has no value with number "
+                        		+ number + ".");
+                    }
+                } else {
+                    String id = parser.getText();
+                    value = enumType.findValueByName(id);
+                    if (value == null) {
+                    	throw new RuntimeException("Enum type \""
+                    			+ enumType.getFullName()
+                    			+ "\" has no value named \""
+                    			+ id + "\".");
+                    }
+                }
+                break;
+            }
+
+            case MESSAGE:
+            case GROUP:
+                throw new RuntimeException("Can't get here.");
+        }
+        return value;
+    }
+    
+
+    private static Object handleObject(JsonParser parser,
+                                       ExtensionRegistry extensionRegistry,
+                                       Message.Builder builder,
+                                       FieldDescriptor field,
+                                       ExtensionRegistry.ExtensionInfo extension,
+                                       boolean unknown) throws IOException {
+
+        Message.Builder subBuilder;
+        if (extension == null) {
+            subBuilder = builder.newBuilderForField(field);
+        } else {
+            subBuilder = extension.defaultInstance.newBuilderForType();
+        }
+
+        JsonToken token = parser.getCurrentToken();
+
+        if (unknown) {
+        	ByteString data = ByteString.copyFrom(parser.getBinaryValue());
+            try {
+                subBuilder.mergeFrom(data);
+                return subBuilder.build();
+            } catch (InvalidProtocolBufferException e) {
+                throw new RuntimeException("Failed to build " + field.getFullName() + " from " + data);
+            }
+        }
+
+        //token = parser.nextToken();
+        if (token.equals(JsonToken.START_OBJECT)) {
+	        token = parser.nextToken();
+	        while (token != null && !token.equals(JsonToken.END_OBJECT)) {
+	            mergeField(parser, extensionRegistry, subBuilder);
+	            token = parser.nextToken();
+	        }
+        }
+        return subBuilder.build();
+    }
+
+    // =================================================================
+    // Utility functions
+    //
+    // Some of these methods are package-private because Descriptors.java uses
+    // them.
+    
+    /**
+     * Convert an unsigned 32-bit integer to a string.
+     */
+    private static Integer unsignedInt(int value) {
+        if (value < 0) {
+            return (int) ((value) & 0x00000000FFFFFFFFL);
+        }
+        return value;
+    }
+
+    /**
+     * Convert an unsigned 64-bit integer to a string.
+     */
+    private static Long unsignedLong(long value) {
+        if (value < 0) {
+            // Pull off the most-significant bit so that BigInteger doesn't think
+            // the number is negative, then set it again using setBit().
+            return BigInteger.valueOf(value & 0x7FFFFFFFFFFFFFFFL).setBit(63).longValue();
+        }
+        return value;
+    }
+}

File diff suppressed because it is too large
+ 1333 - 0
gis_scene/src/main/java/com/gis/scene/proto/format/XmlFormat.java


+ 162 - 0
gis_scene/src/main/java/com/gis/scene/proto/util/ConvertUtils.java

@@ -0,0 +1,162 @@
+package com.gis.scene.proto.util;
+
+import com.gis.scene.proto.Visionmodeldata;
+import com.gis.scene.proto.format.JsonFormat;
+import lombok.extern.log4j.Log4j2;
+
+import java.io.*;
+import java.util.ArrayList;
+import java.util.List;
+
+@Log4j2
+public class ConvertUtils {
+
+    public static void convertVisionModelDataToTxt(String srcPath, String desPath) throws Exception {
+
+        BufferedOutputStream bos = null;
+        BufferedInputStream bis = null;
+        try {
+            File file = new File(srcPath);
+            FileInputStream fis = new FileInputStream(file);
+
+            Visionmodeldata.NavigationInfo data_NavigationInfo = Visionmodeldata.NavigationInfo.parseFrom(fis);
+
+            String jsonFormat1 = JsonFormat.printToString(data_NavigationInfo);
+            ByteArrayInputStream stream = new ByteArrayInputStream(jsonFormat1.getBytes());
+            bos = new BufferedOutputStream(new FileOutputStream(desPath));//设置输出路径
+            bis = new BufferedInputStream(stream);
+            int b = -1;
+            while ((b = bis.read()) != -1) {
+                bos.write(b);
+            }
+            //out.close();
+            bis.close();
+            bos.close();
+        } catch (Exception e) {
+            StringWriter trace = new StringWriter();
+            e.printStackTrace(new PrintWriter(trace));
+            log.error(trace.toString());
+        } finally {
+            if (bos != null) {
+                bos.close();
+            }
+            if (bis != null) {
+                bis.close();
+            }
+        }
+    }
+
+    public static void convertTxtToVisionModelData(String srcPath, String desPath) throws Exception {
+        BufferedOutputStream bos = null;
+        BufferedInputStream bis = null;
+        try {
+            Visionmodeldata.NavigationInfo.Builder builder = Visionmodeldata.NavigationInfo.newBuilder();
+            String jsonFormat = readTxtFileToJson(srcPath);
+            JsonFormat.merge(jsonFormat, builder);
+            byte[] buf = builder.build().toByteArray();
+
+            //把序列化后的数据写入本地磁盘
+            ByteArrayInputStream stream = new ByteArrayInputStream(buf);
+            bos = new BufferedOutputStream(new FileOutputStream(desPath));//设置输出路径
+            bis = new BufferedInputStream(stream);
+            int b = -1;
+            while ((b = bis.read()) != -1) {
+                bos.write(b);
+            }
+            bis.close();
+            bos.close();
+        } catch (Exception e) {
+            StringWriter trace = new StringWriter();
+            e.printStackTrace(new PrintWriter(trace));
+            log.error(trace.toString());
+        } finally {
+            if (bos != null) {
+                bos.close();
+            }
+            if (bis != null) {
+                bis.close();
+            }
+        }
+    }
+
+    public static String readTxtFileToJson(String filePath) {
+        try {
+            String encoding = "UTF-8";
+            File file = new File(filePath);
+            if (file.isFile() && file.exists()) {
+                InputStreamReader read = new InputStreamReader(
+                        new FileInputStream(file), encoding);
+                BufferedReader bufferedReader = new BufferedReader(read);
+                String lineTxt = null;
+                String result = "";
+                while ((lineTxt = bufferedReader.readLine()) != null) {
+                    result += lineTxt;
+                }
+                read.close();
+                return result;
+            } else {
+                return null;
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+            return null;
+        }
+    }
+
+
+    public List<List<String>> descartes(List<List<String>> dimValue) {
+        List<List<String>> res = new ArrayList<>();
+        if (dimValue == null || dimValue.size() == 0)
+            return res;
+        backtrace(dimValue, 0, res, new ArrayList<>());
+        return res;
+
+    }
+
+    /**
+     * 递归回溯法求解
+     *
+     * @param dimValue 原始数据集合
+     * @param index 当前执行的集合索引
+     * @param result 结果集合
+     * @param curList 当前的单个结果集
+     */
+    private void backtrace(List<List<String>> dimValue, int index,
+                           List<List<String>> result, List<String> curList) {
+
+        if (curList.size() == dimValue.size())
+            result.add(new ArrayList<>(curList));
+        else
+            for (int j = 0; j < dimValue.get(index).size(); j++) {
+                curList.add(dimValue.get(index).get(j));
+                backtrace(dimValue, index + 1, result, curList);
+                curList.remove(curList.size() - 1);
+            }
+
+    }
+
+    public static void main(String[] args) {
+        List<String> list1 = new ArrayList<String>();
+        list1.add("普通会员");
+        list1.add("专业会员");
+        list1.add("商业会员");
+        List<String> list2 = new ArrayList<String>();
+        list2.add("1G");
+        list2.add("1T");
+        List<List<String>> dimValue = new ArrayList<List<String>>();
+        dimValue.add(list1);
+        dimValue.add(list2);
+
+        // 递归实现笛卡尔积
+        ConvertUtils s = new ConvertUtils();
+        List<List<String>> res = s.descartes(dimValue);
+        System.out.println("递归实现笛卡尔乘积: 共 " + res.size() + " 个结果");
+        for (List<String> list : res) {
+            for (String string : list) {
+                System.out.print(string + " ");
+            }
+            System.out.println();
+        }
+    }
+
+}

+ 233 - 0
gis_scene/src/main/java/com/gis/scene/proto/util/CreateObjUtil.java

@@ -0,0 +1,233 @@
+package com.gis.scene.proto.util;
+
+import com.gis.scene.proto.BigSceneProto;
+import com.gis.scene.proto.Common;
+import com.gis.scene.proto.constant.ConstantCmd;
+import com.gis.scene.proto.constant.ConstantFileName;
+import com.gis.scene.proto.format.JsonFormat;
+import com.gis.scene.proto.Visionmodeldata;
+import com.google.protobuf.TextFormat;
+import lombok.extern.slf4j.Slf4j;
+import org.junit.Test;
+
+import java.io.*;
+
+/**
+ * Created by Owen on 2019/12/17 0017 11:40
+ *
+ * 3d模型数据转换工具类
+ */
+@Slf4j
+public class CreateObjUtil {
+
+
+    /**
+     * 调用算法 xx.sh 脚本
+     * @param command
+     */
+    public static void callshell(String command){
+        try {
+            Process process = Runtime.getRuntime().exec(command);
+            StreamGobbler errorGobbler = new StreamGobbler(process.getErrorStream(), "ERROR");
+            errorGobbler.start();
+            StreamGobbler outGobbler = new StreamGobbler(process.getInputStream(), "STDOUT");
+            outGobbler.start();
+            process.waitFor();
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+
+    /**
+     * txt to dam
+     * @param srcpath txt 地址
+     * @param despath 生成dam地址
+     * @throws Exception
+     */
+    public static void convertTxtToDam(String srcpath,String despath)throws Exception
+    {
+        try
+        {
+            BigSceneProto.binary_mesh.Builder builder= BigSceneProto.binary_mesh.newBuilder();
+            InputStream inputStream = new FileInputStream(srcpath);
+            InputStreamReader reader = new InputStreamReader(inputStream, "ASCII");
+            TextFormat.merge(reader, builder);
+            byte[] buf= builder.build().toByteArray();
+
+
+            //把序列化后的数据写入本地磁盘
+            ByteArrayInputStream stream = new ByteArrayInputStream(buf);
+            BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(despath));//设置输出路径
+            BufferedInputStream bis = new BufferedInputStream(stream);
+            int b = -1;
+            while ((b = bis.read()) != -1) {
+                bos.write(b);
+            }
+            bis.close();
+            bos.close();
+        }
+        catch(Exception e)
+        {
+            StringWriter trace=new StringWriter();
+            e.printStackTrace(new PrintWriter(trace));
+            log.error(trace.toString());
+        }
+    }
+
+
+    public static void convertDamToLzma(String folderName)throws Exception {
+        log.info("folderName: {}", folderName);
+        try {
+            String command = "lzma "+ folderName + ConstantFileName.modelUUID+"_50k.dam";
+            log.info("开始转换lzma :{}", command );
+            callshell(command);
+            log.info("转换lzma完毕");
+        }
+        catch(Exception e)
+        {
+            StringWriter trace=new StringWriter();
+            e.printStackTrace(new PrintWriter(trace));
+            log.error(trace.toString());
+        }
+
+    }
+
+
+    /**
+     * vision.txt转vision.modeldata
+     * @param srcpath
+     * @param despath
+     * @throws Exception
+     */
+    public static void convertTxtToVisionmodeldata(String srcpath,String despath)throws Exception
+    {
+        try
+        {
+            Visionmodeldata.NavigationInfo.Builder builder = Visionmodeldata.NavigationInfo.newBuilder();
+            String jsonFormat = readTxtFileToJson(srcpath);
+            JsonFormat.merge(jsonFormat, builder);
+            byte[] buf= builder.build().toByteArray();
+
+            //把序列化后的数据写入本地磁盘
+            ByteArrayInputStream stream = new ByteArrayInputStream(buf);
+            BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(despath));//设置输出路径
+            BufferedInputStream bis = new BufferedInputStream(stream);
+            int b = -1;
+            while ((b = bis.read()) != -1) {
+                bos.write(b);
+            }
+            bis.close();
+            bos.close();
+        }
+        catch(Exception e)
+        {
+            StringWriter trace=new StringWriter();
+            e.printStackTrace(new PrintWriter(trace));
+            log.error(trace.toString());
+        }
+    }
+
+    public static String readTxtFileToJson(String filePath){
+        try {
+            String encoding="UTF-8";
+            File file=new File(filePath);
+            if(file.isFile() && file.exists()){
+                InputStreamReader read = new InputStreamReader(
+                        new FileInputStream(file),encoding);
+                BufferedReader bufferedReader = new BufferedReader(read);
+                String lineTxt = null;
+                String result="";
+                while((lineTxt = bufferedReader.readLine()) != null){
+                    result+=lineTxt;
+                    //log.info(lineTxt);
+                }
+                read.close();
+                return result;
+            }else{
+                return null;
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+            return null;
+        }
+
+    }
+
+    //开始建模
+    public static void build3dModel(String folderName,String isModel) throws Exception{
+        log.info("开始建模");
+        String command = ConstantCmd.BUILD_MODEL_COMMAND+folderName;
+        // cmd: bash /home/ubuntu/bin/Launcher.sh /data/kanfang/10002/pano
+        log.info("cmd: {}",command);
+        callshell(command);
+        log.info("计算完毕:" + command);
+    }
+
+    public static void convertTxtToVisionmodeldataCommon(String srcpath,String despath)throws Exception
+    {
+        try
+        {
+            Common.NavigationInfo.Builder builder = Common.NavigationInfo.newBuilder();
+            String jsonFormat = readTxtFileToJson(srcpath);
+            log.warn("jsonFormat: {}", jsonFormat);
+
+            // 临时处理,等算法处理好这个问题,可以删除此方法
+            jsonFormat = deviceJson(jsonFormat);
+
+            JsonFormat.merge(jsonFormat, builder);
+            byte[] buf= builder.build().toByteArray();
+
+            //把序列化后的数据写入本地磁盘
+            ByteArrayInputStream stream = new ByteArrayInputStream(buf);
+            BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(despath));//设置输出路径
+            BufferedInputStream bis = new BufferedInputStream(stream);
+            int b = -1;
+            while ((b = bis.read()) != -1) {
+                bos.write(b);
+            }
+            bis.close();
+            bos.close();
+        }
+        catch(Exception e)
+        {
+            StringWriter trace=new StringWriter();
+            e.printStackTrace(new PrintWriter(trace));
+            log.error(trace.toString());
+        }
+    }
+
+
+    private static String deviceJson(String str) {
+        String rep = "\"device\":vision_\\d,";
+        if (str.contains("\"device\":vision")) {
+            log.warn("device 临时特殊处理一下");
+            str = str.replaceAll(rep, "");
+        }
+        log.info("update json: {}", str);
+        return str;
+    }
+
+    public static void main(String[] args) {
+
+        String path = "F:\\test\\army\\convert\\";
+        try {
+            convertTxtToVisionmodeldata(path+"vision.txt", path+"vision.modeldata");
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+
+    @Test
+    public void modelDataTxtToDamTest(){
+        String path = "F:\\test\\army\\convert\\";
+//        ConstantFileName.modelUUID+"_50k.dam"
+        try {
+            convertTxtToDam(path+"test.txt", path+ConstantFileName.modelUUID+"_50k.dam");
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+}

+ 61 - 0
gis_scene/src/main/java/com/gis/scene/proto/util/StreamGobbler.java

@@ -0,0 +1,61 @@
+package com.gis.scene.proto.util;
+
+import java.io.*;
+
+public class StreamGobbler extends Thread {
+
+	InputStream is;  
+    String type;  
+    OutputStream os;  
+
+    public StreamGobbler(InputStream is, String type) {  
+        this(is, type, null);  
+    }  
+
+    StreamGobbler(InputStream is, String type, OutputStream redirect) {  
+        this.is = is;  
+        this.type = type;  
+        this.os = redirect;  
+    }  
+
+    public void run() {  
+        InputStreamReader isr = null;  
+        BufferedReader br = null;  
+        PrintWriter pw = null;  
+        try {  
+            if (os != null)  
+                pw = new PrintWriter(os);  
+
+            isr = new InputStreamReader(is);  
+            br = new BufferedReader(isr);  
+            String line=null;  
+            while ( (line = br.readLine()) != null) {  
+                if (pw != null)  
+                    pw.println(line);  
+                System.out.println(type + ">" + line);      
+            }  
+
+            if (pw != null)  
+                pw.flush();  
+        } catch (IOException ioe) {  
+            ioe.printStackTrace();    
+        } finally{  
+            try {  
+            	if(pw!=null)
+            	{
+            		 pw.close();  
+            	}
+            	if(br!=null)
+            	{
+            		br.close();  
+            	}
+            	if(isr!=null)
+            	{
+            		isr.close();  
+            	}
+            } catch (IOException e) {  
+                e.printStackTrace();  
+            }  
+        }  
+    }  
+}

+ 37 - 0
gis_scene/src/main/java/com/gis/scene/service/SceneService.java

@@ -0,0 +1,37 @@
+package com.gis.scene.service;
+
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.gis.common.base.entity.dto.PageDto;
+import com.gis.common.base.service.IBaseService;
+import com.gis.common.util.Result;
+import com.gis.scene.entity.dto.RoamViableDto;
+import com.gis.scene.entity.dto.SceneDataDto;
+import com.gis.scene.entity.po.SceneEntity;
+import org.springframework.web.multipart.MultipartFile;
+
+
+/**
+ * Created by owen on 2020/3/11 0011 16:14
+ */
+public interface SceneService extends IService<SceneEntity> {
+
+
+    SceneEntity findBySceneCode(String m);
+
+    Result<SceneEntity> search(PageDto param);
+
+    Result roamViable(RoamViableDto param) throws Exception;
+
+    Result edit(SceneDataDto param);
+
+    Result display(Long id);
+
+    Result addStar(Long id);
+
+    Result addVisit(Long id);
+
+    Result upload(MultipartFile file, String sceneCode);
+
+    Result del(String ids);
+}

+ 453 - 0
gis_scene/src/main/java/com/gis/scene/service/impl/SceneServiceImpl.java

@@ -0,0 +1,453 @@
+package com.gis.scene.service.impl;
+
+import cn.hutool.core.io.FileUtil;
+import cn.hutool.core.util.StrUtil;
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.alibaba.fastjson.serializer.SerializerFeature;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.gis.common.base.entity.dto.PageDto;
+import com.gis.common.base.exception.BaseRuntimeException;
+import com.gis.common.constant.ConfigConstant;
+import com.gis.common.util.BaseUtil;
+import com.gis.common.util.FileUtils;
+import com.gis.common.util.Result;
+import com.gis.scene.entity.dto.RoamViableDto;
+import com.gis.scene.entity.dto.SceneDataDto;
+import com.gis.scene.entity.po.SceneEntity;
+import com.gis.scene.mapper.SceneMapper;
+import com.gis.scene.proto.util.ConvertUtils;
+import com.gis.scene.service.SceneService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+
+/**
+ * Created by owen on 2020/3/11 0011 16:16
+ */
+@Slf4j
+@Service
+public class SceneServiceImpl extends ServiceImpl<SceneMapper,SceneEntity> implements SceneService {
+
+
+    @Autowired
+    ConfigConstant configConstant;
+
+    @Autowired
+    FileUtils fileUtils;
+
+
+    @Override
+    public SceneEntity findBySceneCode(String m) {
+        return baseMapper.findBySceneCode(m);
+    }
+
+    @Override
+    public Result<SceneEntity> search(PageDto param) {
+        BaseUtil.startPage(param);
+        IPage<SceneEntity> page = new Page<>(param.getPageNum(), param.getPageSize());
+
+        LambdaQueryWrapper<SceneEntity> wrapper = new LambdaQueryWrapper<>();
+        String searchKey = param.getSearchKey();
+        wrapper.like(StrUtil.isNotBlank(searchKey), SceneEntity::getSceneTitle, searchKey);
+        wrapper.orderByDesc(SceneEntity::getCreateTime);
+
+        return Result.success(this.page(page, wrapper));
+    }
+
+    /**
+     * 漫游可行
+     */
+    @Override
+    public Result roamViable(RoamViableDto param) throws Exception {
+        String sceneCode = param.getSceneCode();
+        SceneEntity entity = baseMapper.findBySceneCode(param.getSceneCode());
+        if (entity == null) {
+            log.error("场景不存在:{}", sceneCode);
+            return Result.failure("场景不存在");
+        }
+
+
+        // 1. 从oss下载vision.modeldata
+        String visionModelDataName = "vision.modeldata";
+        // 注意网络下载会有缓存,必须加时间戳
+        String localBasePath = configConstant.serverBasePath +"/data/" + sceneCode;
+
+        // 2. 将vision.modeldata 转 vision.json
+        String visionModelDataPath = localBasePath + "/" + visionModelDataName;
+        if (!FileUtil.exist(visionModelDataPath)) {
+            log.error("vision.modeldata不存在 : {}", visionModelDataPath);
+            return Result.failure("vision.modeldata不存在");
+        }
+
+
+        String visionJsonPath = localBasePath + "/vision.json";
+        ConvertUtils.convertVisionModelDataToTxt(visionModelDataPath, visionJsonPath);
+        if (!FileUtil.exist(visionJsonPath)) {
+            log.error("vision.json不存在 : {}", visionJsonPath);
+            return Result.failure("vision.modeldata不存在");
+        }
+
+        // 3. 编辑新数据到vision.json
+        JSONArray inputDates = JSONObject.parseArray(param.getData());
+
+        JSONObject visionJson = JSONObject.parseObject(FileUtil.readUtf8String(visionJsonPath));
+        JSONArray sweepLocations = visionJson.getJSONArray("sweepLocations");
+
+        for (int i = 0; i < sweepLocations.size(); i++) {
+            JSONObject pano = sweepLocations.getJSONObject(i);
+
+            for (int j = 0; j < inputDates.size(); j++) {
+                JSONObject jo = inputDates.getJSONObject(j);
+                String panoID = jo.getString("panoID");
+                JSONArray visibles3 = jo.getJSONArray("visibles3");
+
+                // 去掉uuid 的“-”
+                String uuid = pano.getString("uuid");
+//                String s = StringUtils.replaceAll(uuid, "-", "");
+                String s = uuid.replaceAll("-", "");
+                if (s.equals(panoID)) {
+                    log.info("uuid: {}, panoID: {}", uuid, panoID);
+                    pano.put("visibles", visibles3);
+                    log.info("visibles: {},visibles3:{}", pano.get("visibles"), visibles3);
+                }
+            }
+        }
+
+
+        // 删除旧vision.json,vision.modeldata
+        FileUtil.del(visionJsonPath);
+        FileUtil.del(visionModelDataPath);
+
+        // 写入新vision.json
+        FileUtil.writeUtf8String(visionJson.toJSONString(), visionJsonPath);
+        if (!FileUtil.exist(visionJsonPath)) {
+            log.error("new vision.json不存在");
+        }
+
+        log.info( "新vision.json创建完成 :{}", visionJsonPath);
+
+
+
+
+        // 4. 将vision.json转vision.modeldata
+        ConvertUtils.convertTxtToVisionModelData(visionJsonPath, visionModelDataPath);
+
+        // 5. 将新的vision.modeldata上传到oss
+        if (!FileUtil.exist(visionModelDataPath)) {
+            log.error("vision.modeldata不存在");
+        }
+        log.info("新" + visionModelDataName+ "创建完成 :{}", visionModelDataPath);
+
+
+        return Result.success();
+    }
+
+
+    @Override
+    public Result edit(SceneDataDto param){
+
+        String sceneCode = param.getSceneCode();
+        BaseRuntimeException.isBlank(sceneCode, null, "场景码参数不能为空");
+        String basePath = configConstant.serverBasePath +"/data/" + sceneCode;
+
+        // 处理someData.json
+        doSomeData(param, sceneCode, basePath);
+        // 处理data2.js
+        doData2Js(param, basePath);
+        // 处理data.js
+        doDataJs(param.getHots(), basePath);
+
+
+        return Result.success();
+    }
+
+    private void doSomeData(SceneDataDto param, String sceneCode, String basePath) {
+        SceneEntity entity = this.findBySceneCode(sceneCode);
+        BaseRuntimeException.isNull(entity, null, "场景不存在:" + sceneCode);
+
+
+
+        String someDataPath = basePath + "/someData.json";
+        BaseRuntimeException.isTrue(!FileUtil.isFile(someDataPath), null, "someData.json文件不存在");
+
+        // 读取someDataJson
+        String someData = FileUtil.readUtf8String(someDataPath);
+        JSONObject someDataJson = JSONObject.parseObject(someData);
+
+
+        String info = param.getInfo();
+        String guides = param.getGuides();
+        JSONArray guidesArray = new JSONArray();
+        if (guides != null) {
+            guidesArray = JSONObject.parseArray(guides);
+
+        }
+
+
+        if (info != null) {
+            JSONObject infoJson = JSONObject.parseObject(info);
+            // 更新title
+            String name = infoJson.getString("name");
+            if (!StrUtil.equals(name, entity.getSceneTitle())){
+                entity.setSceneTitle(name);
+                this.updateById(entity);
+            }
+            // 处理model
+            JSONObject model = someDataJson.getJSONObject("model");
+            if (model != null) {
+                if (guidesArray != null) {
+                    model.put("images", guidesArray);
+                }
+
+            }
+
+            // 更新someDataJson
+            someDataJson.put("model", model);
+
+            // info信息添加到someDataJson最外层
+            Set<String> infoKey = infoJson.keySet();
+            for (String key : infoKey) {
+                someDataJson.put(key, infoJson.get(key));
+            }
+
+            // 删除旧someDataJson
+            FileUtil.del(someDataPath);
+            // 写入新someDataJson
+            FileUtil.writeUtf8String(someDataJson.toJSONString(), someDataPath);
+            log.info("处理完成: someData.json已写入服务");
+        }
+    }
+
+    private void doData2Js(SceneDataDto param, String basePath) {
+
+        // 使用参数
+        String guides = param.getGuides();
+        String tourAudio = param.getTourAudio();
+
+        String data2Path = basePath + "/data2.js";
+        BaseRuntimeException.isTrue(!FileUtil.isFile(data2Path), null, "data2.js文件不存在");
+
+
+        String data2 = FileUtil.readUtf8String(data2Path);
+        JSONObject data2Json = JSONObject.parseObject(data2);
+
+
+        if (tourAudio != null) {
+            data2Json.put("tourAudio", JSONObject.parseObject(tourAudio));
+        } else {
+            data2Json.put("tourAudio", new JSONObject());
+        }
+
+        // overlays是数组
+        String overlays = param.getOverlays();
+        if (overlays != null) {
+            data2Json.put("overlays", JSONObject.parseArray(overlays));
+        } else {
+            data2Json.put("overlays", new JSONArray());
+        }
+
+        // 处理guidesArray,将scan_id的值作为key, value:  time":40000
+        JSONObject audioJson = new JSONObject();
+        JSONObject timeJson = new JSONObject();
+        timeJson.put("time", 40000);
+        JSONArray guidesArray = new JSONArray();
+        if (guides != null) {
+            guidesArray = JSONObject.parseArray(guides);
+
+        }
+        if (guidesArray != null) {
+
+            // 将旧的audio字段删除
+            data2Json.remove("audio");
+
+            for (int i = 0; i < guidesArray.size() ; i++) {
+                JSONObject metadata = guidesArray.getJSONObject(i).getJSONObject("metadata");
+                if (metadata != null) {
+                    String scanId = metadata.getString("scan_id");
+                    BaseRuntimeException.isNull(scanId, null, "guides.metadata.scan_id为空: " + i);
+                    // Fastjson-fastjson中$ref对象重复引用问题,拿不到想要的效果
+                    audioJson.put(scanId, JSON.toJSONString(timeJson, SerializerFeature.DisableCircularReferenceDetect));
+
+                }
+            }
+
+            // 新增audio
+            data2Json.put("audio", audioJson);
+        }
+
+
+        // host在data2.js、data.js都需要处理
+        String hots = param.getHots();
+        log.info("input hots: {}", hots);
+        if (hots != null) {
+            // 获取所有key
+            JSONObject hotJson = JSONObject.parseObject(hots);
+
+            Set<String> strings = hotJson.keySet();
+            for (String key: strings) {
+                JSONObject subJson = hotJson.getJSONObject(key);
+
+                // 2021.04.02 处理link
+                String link = getLink(subJson, key);
+
+                // 将link 添加进去
+                subJson.put("link", link);
+            }
+            data2Json.put("hots", hotJson);
+        } else {
+            data2Json.put("hots", new JSONObject());
+        }
+
+        // 删除旧data2.js
+        FileUtil.del(data2Path);
+
+        // 写入新data2.js
+        FileUtil.writeUtf8String(data2Json.toJSONString(), data2Path);
+        log.info("处理完成: data2.js已写入服务");
+    }
+
+    private void doDataJs(String hots, String basePath) {
+
+        // 因为data.js只是热点信息,所以直接创建上传oss
+        JSONObject dataJsJson = new JSONObject();
+        if (hots != null) {
+            dataJsJson = JSONObject.parseObject(hots);
+
+            Set<String> strings = dataJsJson.keySet();
+            for (String key: strings) {
+                JSONObject subJson = dataJsJson.getJSONObject(key);
+                JSONObject infoAttribute = subJson.getJSONObject("infoAttribute");
+                if (infoAttribute != null) {
+                    Set<String> infoKey = infoAttribute.keySet();
+
+                    for (String s: infoKey) {
+                        Object val = null;
+                        // 添加到第一层, 空值不添加
+                        if ("images".equals(s) || "styleImg".equals(s) || "model".equals(s) || "video".equals(s) || "iframe".equals(s)) {
+                            JSONArray jsonArray = infoAttribute.getJSONArray(s);
+                            if (jsonArray.size() == 0) {
+                                continue;
+                            }
+                            val = jsonArray;
+
+                        } else {
+                            String a = infoAttribute.getString(s);
+                            if (StrUtil.isBlank(a)){
+                                continue;
+                            }
+                            val = a;
+                        }
+
+
+                        subJson.put(s, val);
+                    }
+
+                }
+
+                // 删除infoAttribute
+                subJson.remove("infoAttribute");
+
+            }
+
+        }
+
+        log.info("out data.js : {}", dataJsJson);
+
+        String dataPath = basePath + "/hot/js/data.js";
+        FileUtil.writeUtf8String(dataJsJson.toJSONString(), dataPath);
+        log.info("data.js保存路径: {}", dataPath);
+        log.info("处理完成: data.js已写入服务");
+
+    }
+
+
+
+    @Override
+    public Result display(Long id) {
+        SceneEntity entity = this.getById(id);
+        if (entity == null) {
+            return Result.failure("场景不存在, id: " + id);
+        }
+        // 需求:只有一个是可用;先禁用,再启用
+        baseMapper.setDisable();
+        baseMapper.setDisplay(id);
+        return Result.success();
+    }
+
+    @Override
+    public Result addStar(Long id) {
+        baseMapper.addStar(id);
+        return Result.success();
+    }
+
+    @Override
+    public Result addVisit(Long id) {
+        baseMapper.addVisit(id);
+        return Result.success();
+    }
+
+
+    @Override
+    public Result upload(MultipartFile file, String sceneCode) {
+        if (file == null) {
+            log.error("文件不能为空");
+            return Result.failure("文件不能为空");
+        }
+
+        SceneEntity entity = this.findBySceneCode(sceneCode);
+        if (entity == null) {
+            log.error("场景不存在: {}", sceneCode);
+            return Result.failure("场景不存在");
+        }
+
+        Map<String, Object> uploadMap = fileUtils.uploadMap(file, "/data/" + sceneCode + "/edit/hot", false);
+
+        return Result.success(uploadMap.get("filePath"));
+    }
+
+    @Override
+    public Result del(String ids) {
+        String[] split = ids.split(",");
+        List<SceneEntity> entities = this.listByIds(Arrays.asList(split));
+
+        for (SceneEntity entity: entities) {
+            // 删除服务器器文件
+            String sceneCode = entity.getSceneCode();
+            if (StrUtil.isNotBlank(sceneCode)){
+                fileUtils.del("/data/" + entity.getSceneCode());
+            }
+
+            this.removeById(entity);
+        }
+
+        return null;
+    }
+
+
+    /**
+     * 2021.04.02 处理infoAttribute的m_title
+     * String url  = "https://www.4dmodel.com/SuperTwo/hot_online/index.html?m=" + key;
+     * String url  = SERVER_DOMAIN + "edit-backstage/hot_online/index.html?m=" + key;
+     * m_title:[]
+     * 有值: link = "/edit-backstage/hot_online1/index.html?m=" + key
+     * 无值: link = "/edit-backstage/hot_online/index.html?m=" + key
+     */
+    private String getLink(JSONObject param, String key){
+        String url  = "/edit-backstage/hot_online1/index.html#/?m=" + key;
+        return url;
+    }
+
+
+}

+ 6 - 0
pom.xml

@@ -21,6 +21,7 @@
     <module>gis_admin</module>
     <module>gis_application</module>
     <module>gis_cms</module>
+    <module>gis_scene</module>
   </modules>
 
 
@@ -80,6 +81,11 @@
         <version>${gis.version}</version>
       </dependency>
 
+      <dependency>
+        <groupId>com.gis</groupId>
+        <artifactId>gis_scene</artifactId>
+        <version>${gis.version}</version>
+      </dependency>