index.php
<?php
$url = "http://localhost:8080/geoserver/rest/styles";
$curl = curl_init($url);
$options = array(
//HEADER
CURLOPT_HTTPHEADER => array(
'Content-Type: application/vnd.ogc.sld+xml',
),
//BASIC認証
CURLOPT_USERPWD=>"admin:geoserver",
//Method
CURLOPT_CUSTOMREQUEST => "POST",
//Body
CURLOPT_POSTFIELDS => file_get_contents("test.xml"),
);
//set options
curl_setopt_array($curl, $options);
// request
$result = curl_exec($curl);
$info = curl_getinfo($curl);
echo "<pre>";
echo print_r($info);
echo "</pre>";
test.xml
<?xml version="1.0" encoding="UTF-8"?>
<StyledLayerDescriptor version="1.0.0" xmlns="http://www.opengis.net/sld" xmlns:ogc="http://www.opengis.net/ogc"
xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.opengis.net/sld http://schemas.opengis.net/sld/1.0.0/StyledLayerDescriptor.xsd">
<NamedLayer>
<Name>poi_2</Name>
<UserStyle>
<Name>poi_2</Name>
<Title>Points of interest</Title>
<Abstract>Manhattan points of interest</Abstract>
<FeatureTypeStyle>
<Rule>
<PointSymbolizer>
<Graphic>
<Mark>
<WellKnownName>circle</WellKnownName>
<Fill>
<CssParameter name="fill">#FF0000</CssParameter>
<CssParameter name="fill-opacity">1.0</CssParameter>
</Fill>
</Mark>
<Size>11</Size>
</Graphic>
</PointSymbolizer>
<PointSymbolizer>
<Graphic>
<Mark>
<WellKnownName>circle</WellKnownName>
<Fill>
<CssParameter name="fill">#EDE513</CssParameter>
<CssParameter name="fill-opacity">1.0</CssParameter>
</Fill>
</Mark>
<Size>7</Size>
</Graphic>
</PointSymbolizer>
</Rule>
</FeatureTypeStyle>
</UserStyle>
</NamedLayer>
</StyledLayerDescriptor>
関連
コメント