geoserver上传kml无格式

时间:2017-01-19 09:59:45

标签: api geoserver

我正在使用地理服务器的API(link)将新的kml文件上传到mu本地计算机,并使用以下json的http://localhost:8080/geoserver/rest/imports发送请求

{
   "import": {
      "targetWorkspace": {
         "workspace": {
            "name": "sample"
         }
      },
      "targetStore": {
         "dataStore": {
            "name": "sample"
         }
      },
      "data": {
        "type": "file",
        "file": "/data/sample_dir/sample.kml"
      }
   }
}

我应该根据API文档获得响应的数据类型和状态,但是我得到一个挂起的文件格式。 响应:

{
    "import": {
        "id": 23,
        "href": "http://localhost:8080/geoserver/rest/imports/23",
        "state": "PENDING",
        "archive": false,
        "targetWorkspace": {
            "workspace": {
                "name": "sample"
            }
        },
        "targetStore": {
            "dataStore": {
                "name": "sample",
                "type": "Directory of spatial files (shapefiles)"
            }
        },
        "data": {
            "type": "file",
            "format": null,
            "file": "sample.kml"
        },
        "tasks": []
    }
}

1 个答案:

答案 0 :(得分:0)

显然,地理服务器不接受API文档中所说的相对路径。 如果不是:

"data": {
        "type": "file",
        "file": "./data/sample_dir/sample.kml"
      }

我用

"data": {
        "type": "file",
        "file": "/var/lib/tomcat7/webapps/geoserver/data/sample_dir/sample.kml"
      }

对请求它工作正常。