2014-12-11 2 views
0

GeoServer (v2.5.2) 및 GeoWebcache를 사용하는 프로젝트에서 작업하고 있습니다. 커버리지 스토어와 관련 레이어를 만들기 위해 이미지를 업로드하고 싶습니다. PHP와 cURL을 사용하여 REST API와 통신하고 있습니다. GeoServer - REST API를 사용하여 레이어 추가 (PHP 사용)

업로드 및 커버리지 저장소의 생성

이 코드를 사용하여 작동 :

$curl = curl_init($service_url."workspaces/".htmlentities($workspace)."/coveragestores"); 
     $data = '<coverageStore> 
         <name>'.htmlentities($name).'</name> 
         <type>'.htmlentities($type).'</type> 
         <enabled>true</enabled> 
         <connectionParameters> 
          <entry key="url">file:'.$file.'</entry> 
          <entry key="namespace">'.htmlentities($workspace, ENT_COMPAT).'</entry> 
         </connectionParameters> 
        </coverageStore>'; 
     curl_setopt($curl, CURLOPT_POST, True); 
     curl_setopt($curl, CURLOPT_HTTPHEADER,array("Content-type: application/xml, Content-Length: ".strlen($data))); 
     curl_setopt($curl, CURLOPT_POSTFIELDS, $data); 
     curl_setopt($curl, CURLOPT_USERPWD, $auth); 
     curl_setopt($curl, CURLOPT_HEADER, false); 
     curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); 
     $buffer = curl_exec($curl); 

가 지금은 새 레이어를 만들려고합니다. 위와 동일한 코드를 사용하고 있습니다 (URL 및 XML 매개 변수 만 변경). 내가 찾은

최고 "문서는"이 하나입니다 GeoWebCache와 GeoServer 버전을 사용하려고 http://docs.geoserver.org/2.5.x/en/user/geowebcache/rest/layers.html , 모두가 나에게 404 오류 코드를 반환합니다.

그래서이 문서를 사용하여 다시 시도했습니다 : http://docs.geoserver.org/2.5.x/en/user/rest/api/layers.html 그러나 POST 매개 변수가 무엇인지 예상하지는 않습니다. 내가 얻는 유일한 것은 500 오류 코드입니다. 내가 잘못 뭐하는 거지

? 고마워.

답변

2

내 실수 발견 : 레이어를 추가하려고했지만 커버리지를 추가해야했지만 레이어가 자동으로 만들어졌습니다.

누군가를 도울 수 있다면

이 내가했던 방법입니다

 $data = '<coverage> 
        <name>'.htmlentities($name).'</name> 
        <title>'.htmlentities($name).'</title> 
        <nativeCRS>'.htmlentities(' 
         GEOGCS["WGS 84", 
         DATUM["World Geodetic System 1984", 
          SPHEROID["WGS 84", 6378137.0, 298.257223563, AUTHORITY["EPSG","7030"]], 
          AUTHORITY["EPSG","6326"]], 
         PRIMEM["Greenwich", 0.0, AUTHORITY["EPSG","8901"]], 
         UNIT["degree", 0.017453292519943295], 
         AXIS["Geodetic longitude", EAST], 
         AXIS["Geodetic latitude", NORTH], 
         AUTHORITY["EPSG","4326"]] 
         ').' 
        </nativeCRS> 
        <supportedFormats> 
         <string>GEOTIFF</string> 
         <string>PNG</string> 
         <string>JPEG</string> 
         <string>TIFF</string> 
        </supportedFormats> 
        <requestSRS> 
         <string>EPSG:4326</string> 
        </requestSRS> 
        <responseSRS> 
         <string>EPSG:4326</string> 
        </responseSRS> 
        <srs>EPSG:4326</srs> 
       </coverage>'; 

$curl = curl_init($service_url."workspaces/".htmlentities($workspace)."/coveragestores/".htmlentities($name)."/coverages"); 
    curl_setopt($curl, CURLOPT_POST, true); 
    curl_setopt($curl, CURLOPT_HTTPHEADER,array("Content-Type: application/xml","Content-Length: ".strlen($data))); 
    curl_setopt($curl, CURLOPT_POSTFIELDS, $data); 
    curl_setopt($curl, CURLOPT_USERPWD, $auth); 
    curl_setopt($curl, CURLOPT_HEADER, false); 
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); 
curl_exec($curl); 
관련 문제