hibernate 保存空间数据到空间库

Posted 73tong

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了hibernate 保存空间数据到空间库相关的知识,希望对你有一定的参考价值。

jsp

<form class="form-horizontal" id="infoForm">
                            <div class="modal-body">
                                <div class="panel-body">
                                    <div class="row">
                                        <input type="hidden" name="gid"  />
                                        <div class="form-group">
                                            <label for="name" class="control-label col-md-3">名称:</label>
                                            <div class="col-md-8">
                                                <input type="text" id="name" name="name" class="form-control "  required/>
                                            </div>
                                            <div class="col-md-1">
                                                <span style="color:red;text-align:center">*</span>
                                            </div>
                                        </div>
                                       
                                        <div class="form-group">
                                            <label for="type" class="control-label col-md-3">基建类型:</label>
                                            <div class="col-md-8">
                                                <select id="type" name="type" class="form-control " >
                                                    <option value=‘‘>请选择基建类型</option>
                                                    <option value=‘瞭望塔‘ >瞭望塔</option>
                                                    <option value=‘通讯塔‘>通讯塔</option>
                                                </select>
                                            </div>
                                        </div>
                                        <div class="form-group" >
                                            <label class="control-label col-md-3">附件:</label>
                                            <div class="col-md-8" id="imgsContent">
                                            </div>
                                        </div>
                                        <!-- 附件 -->
                                        <div class="form-group">
                                            <label for="fileList" class="control-label col-md-3">附件上传:</label>
                                            <div class="col-md-8">
                                                <input type="file" accept="image/*"  multiple="multiple" id="fileList" name="fileList"  class="form-control " />
                                            </div>
                                        </div>
                                        <input type="hidden" id="imgFile" name="imgPath" class="form-control "/>
                                    </div>
                                </div>
                            </div>
                            <div class="modal-footer">
                                <input class="btn btn-success" type="submit" value="保 存" />
                                <input class="btn btn-default" type="reset" value="重 置" />
                            </div>
                        </form>

 

js

$(function(){
            iniTable();
            filter();
            $("#btn_search").click(function(){
                $(‘#mytab‘).bootstrapTable(‘selectPage‘,1);
            });
            $("#infoWindow").on("submit",function(e){
                e.preventDefault();
                var form = new FormData(document.getElementById("infoForm"));
                var url=$("#modalTitle").text()=="新增"?localhostPaht+ctx+‘/resource/observatory/create‘:localhostPaht+ctx+‘/resource/observatory/update‘;
                $.ajax({
                    type: "post",
                    url: url,
                    data: form,
                    dataType: "json",
                    contentType: false,
                    processData: false,
                    success: function(response){
                        $modal.modal(‘hide‘);
                        alert(response.msg);
                        $(‘#mytab‘).bootstrapTable(‘refresh‘);
                    }
                });
            });
        });

 

controller

@RequestMapping(value = "create", method = RequestMethod.POST)
    @ResponseBody
    public Map<String,String> create(@Valid Observatory Observatory, @RequestParam("fileList") CommonsMultipartFile[] files) {
        Map<String,String> maps=new HashMap<String, String>();
        try {
            //img文件上传
            StringBuilder path = new StringBuilder();
            for (CommonsMultipartFile file : files) {
                String url = FtpSftpUtil.fileToFtp(file,folder);
                if (StringUtils.isNoneBlank(url)) {
                    path.append(url).append(";");
                }
            }
            String imgPath=Observatory.getImgPath();
            imgPath=StringUtils.isNoneBlank(Observatory.getImgPath())&&!"null".equals(Observatory.getImgPath())?Observatory.getImgPath()+path.toString():path.toString();
            Observatory.setImgPath(imgPath);
            observatoryService.saveObservatory(Observatory);
            maps.put("msg", MESSAGE_CREATE_SUCCESS);
        } catch (Exception e) {
            LoggerUtil.error(e);
            maps.put("msg", MESSAGE_CREATE_FAIL);
        }
        return maps;
    }

 

service

public void saveObservatory(Observatory entity) {
        Coordinate coord = new Coordinate(entity.getGisx().doubleValue(), entity.getGisy().doubleValue());
        Point point = geometryFactory.createPoint(coord);
        Geometry geom = geometryFactory.createGeometry(point);
        geom.setSRID(2343);
        entity.setGeom(geom);
        observatoryDao.save(entity);
    }

 

以上是关于hibernate 保存空间数据到空间库的主要内容,如果未能解决你的问题,请参考以下文章

休眠空间多边形坐标方向

进程间通信 - 动态链接库中共享内存(利用DLL的2~3G的地址段空间)

浅谈Hibernate缓存机制:一级缓存二级缓存

保存或检索时的 Laravel 空间错误

VSCODE 片段 PHP 自动填充命名空间

JavaScript3