|
|
@@ -222,10 +222,10 @@ getCapabilities();
|
|
|
// create the UI
|
|
|
var layer = new OpenLayers.Layer.Vector("Scratchpad", {
|
|
|
strategies: [new OpenLayers.Strategy.BBOX()],
|
|
|
- projection: new OpenLayers.Projection("EPSG:4326"),
|
|
|
+ projection: new OpenLayers.Projection("EPSG:900913"),
|
|
|
protocol: new OpenLayers.Protocol.WFS({
|
|
|
version: "1.1.0",
|
|
|
- srsName: "EPSG:4326",
|
|
|
+ srsName: "EPSG:900913",
|
|
|
url: wfsUrl,//"http://demo.opengeo.org/geoserver/wfs"
|
|
|
featureNS : "http://opengeo.org",
|
|
|
featureType: "restricted",
|
|
|
@@ -680,6 +680,48 @@ class WpsActionPrzypiszDoRekordu extends WpsActionBase {
|
|
|
}
|
|
|
|
|
|
class WfsAction {
|
|
|
+
|
|
|
+ /**
|
|
|
+ * example: MULTIPOLYGON(((2072016.74395199 7234076.79293037,2072016.74395199 7234115.01144451,2072131.3994944 7234115.01144451,2072131.3994944 7234076.79293037,2072016.74395199 7234076.79293037)))
|
|
|
+ */
|
|
|
+ public function generateGmlFromWKT($wkt) {
|
|
|
+ $gml = '';
|
|
|
+
|
|
|
+ $wktParts = explode('(', $wkt, 2);
|
|
|
+ ob_start();
|
|
|
+ if ('MULTIPOLYGON' == $wktParts[0]) {
|
|
|
+ $points = trim($wktParts[1], '() ');
|
|
|
+ $points = str_replace(',', "\n", $points);
|
|
|
+ ?>
|
|
|
+ <gml:boundedBy>
|
|
|
+ <gml:Envelope srsDimension="2" srsName="http://www.opengis.net/gml/srs/epsg.xml#4326">
|
|
|
+ <gml:lowerCorner>-180 -90</gml:lowerCorner>
|
|
|
+ <gml:upperCorner>180 90</gml:upperCorner>
|
|
|
+ </gml:Envelope>
|
|
|
+ </gml:boundedBy>
|
|
|
+ <og:the_geom>
|
|
|
+ <gml:MultiSurface srsDimension="2" srsName="http://www.opengis.net/gml/srs/epsg.xml#900913">
|
|
|
+ <gml:surfaceMember>
|
|
|
+ <gml:Polygon srsDimension="2">
|
|
|
+ <gml:exterior>
|
|
|
+ <gml:LinearRing srsDimension="2">
|
|
|
+ <gml:posList>
|
|
|
+ <?php echo $points; ?>
|
|
|
+ </gml:posList>
|
|
|
+ </gml:LinearRing>
|
|
|
+ </gml:exterior>
|
|
|
+ </gml:Polygon>
|
|
|
+ </gml:surfaceMember>
|
|
|
+ </gml:MultiSurface>
|
|
|
+ </og:the_geom>
|
|
|
+ <?php
|
|
|
+ }
|
|
|
+ $gml = ob_get_contents();
|
|
|
+ ob_clean();
|
|
|
+
|
|
|
+ return $gml;
|
|
|
+ }
|
|
|
+
|
|
|
public function execute($args) {
|
|
|
/*
|
|
|
* Mapa odczytywanie punktów: http://www.maptiler.org/google-maps-coordinates-tile-bounds-projection/
|
|
|
@@ -690,7 +732,7 @@ class WfsAction {
|
|
|
18.614273071289062 54.33634445792519
|
|
|
18.614273071289062 54.33614429135817
|
|
|
*/
|
|
|
- $buildings = array();
|
|
|
+ $buildingsGml = array();
|
|
|
$db = DB::getDB();
|
|
|
$sql = "select b.`ID`, AsWKT(b.`the_geom`) as the_geom
|
|
|
from `BUILDINGS` as b
|
|
|
@@ -698,14 +740,14 @@ class WfsAction {
|
|
|
";
|
|
|
$res = $db->query($sql);
|
|
|
while ($r = $db->fetch($res)) {
|
|
|
- $buildings[$r->ID] = $r->the_geom;
|
|
|
+ $buildingsGml[$r->ID] = $this->generateGmlFromWKT($r->the_geom);
|
|
|
}
|
|
|
|
|
|
echo '<?xml version="1.0" encoding="UTF-8"?>';
|
|
|
?>
|
|
|
<wfs:FeatureCollection xmlns:nasa="http://nasa.gov" xmlns:topp="http://www.openplans.org/topp" xmlns:usgs="http://www.usgs.gov/" xmlns:ogc="http://www.opengis.net/ogc" xmlns:wfs="http://www.opengis.net/wfs" xmlns:ows="http://www.opengis.net/ows" xmlns:ne="http://naturalearthdata.com" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:gml="http://www.opengis.net/gml" xmlns:osm="http://openstreemap.org" xmlns:nurc="http://www.nurc.nato.int" xmlns:og="http://opengeo.org" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" numberOfFeatures="4" timeStamp="2014-07-16T13:22:43.307Z" xsi:schemaLocation="http://opengeo.org http://demo.opengeo.org:80/geoserver/wfs?service=WFS&version=1.1.0&request=DescribeFeatureType&typeName=og%3Arestricted http://www.opengis.net/wfs http://demo.opengeo.org:80/geoserver/schemas/wfs/1.1.0/wfs.xsd">
|
|
|
<!--
|
|
|
-<?php echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;"> (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r($buildings);echo'</pre>'; ?>
|
|
|
+<?php echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;"> (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r($buildingsGml);echo'</pre>'; ?>
|
|
|
-->
|
|
|
<gml:boundedBy>
|
|
|
<gml:Envelope srsDimension="2" srsName="http://www.opengis.net/gml/srs/epsg.xml#4326">
|
|
|
@@ -714,80 +756,12 @@ class WfsAction {
|
|
|
</gml:Envelope>
|
|
|
</gml:boundedBy>
|
|
|
<gml:featureMembers>
|
|
|
- <og:restricted gml:id="restricted.1">
|
|
|
- <gml:boundedBy>
|
|
|
- <gml:Envelope srsDimension="2" srsName="http://www.opengis.net/gml/srs/epsg.xml#4326">
|
|
|
- <gml:lowerCorner>-180 -90</gml:lowerCorner>
|
|
|
- <gml:upperCorner>180 90</gml:upperCorner>
|
|
|
- </gml:Envelope>
|
|
|
- </gml:boundedBy>
|
|
|
- <og:the_geom>
|
|
|
- <gml:MultiSurface srsDimension="2" srsName="http://www.opengis.net/gml/srs/epsg.xml#4326">
|
|
|
- <gml:surfaceMember>
|
|
|
- <gml:Polygon srsDimension="2">
|
|
|
- <gml:exterior>
|
|
|
- <gml:LinearRing srsDimension="2">
|
|
|
- <gml:posList>18.45703125 54.36775852406841
|
|
|
- 18.6328125 54.36775852406841
|
|
|
- 18.6328125 54.470037612805754
|
|
|
- 18.45703125 54.470037612805754</gml:posList>
|
|
|
- </gml:LinearRing>
|
|
|
- </gml:exterior>
|
|
|
- </gml:Polygon>
|
|
|
- </gml:surfaceMember>
|
|
|
- </gml:MultiSurface>
|
|
|
- </og:the_geom>
|
|
|
- <og:cat>1</og:cat>
|
|
|
- </og:restricted>
|
|
|
- <og:restricted gml:id="restricted.2">
|
|
|
- <gml:boundedBy>
|
|
|
- <gml:Envelope srsDimension="2" srsName="http://www.opengis.net/gml/srs/epsg.xml#4326">
|
|
|
- <gml:lowerCorner>-180 -90</gml:lowerCorner>
|
|
|
- <gml:upperCorner>180 90</gml:upperCorner>
|
|
|
- </gml:Envelope>
|
|
|
- </gml:boundedBy>
|
|
|
- <og:the_geom>
|
|
|
- <gml:MultiSurface srsDimension="2" srsName="http://www.opengis.net/gml/srs/epsg.xml#4326">
|
|
|
- <gml:surfaceMember>
|
|
|
- <gml:Polygon srsDimension="2">
|
|
|
- <gml:exterior>
|
|
|
- <gml:LinearRing srsDimension="2">
|
|
|
- <gml:posList>
|
|
|
-18.613243103027344 54.33614429135817
|
|
|
-18.613243103027344 54.33634445792519
|
|
|
-18.614273071289062 54.33634445792519
|
|
|
-18.614273071289062 54.33614429135817
|
|
|
- </gml:posList>
|
|
|
- </gml:LinearRing>
|
|
|
- </gml:exterior>
|
|
|
- </gml:Polygon>
|
|
|
- </gml:surfaceMember>
|
|
|
- </gml:MultiSurface>
|
|
|
- </og:the_geom>
|
|
|
- <og:cat>2</og:cat>
|
|
|
- </og:restricted>
|
|
|
- <og:restricted gml:id="restricted.3">
|
|
|
- <gml:boundedBy>
|
|
|
- <gml:Envelope srsDimension="2" srsName="http://www.opengis.net/gml/srs/epsg.xml#4326">
|
|
|
- <gml:lowerCorner>-180 -90</gml:lowerCorner>
|
|
|
- <gml:upperCorner>180 90</gml:upperCorner>
|
|
|
- </gml:Envelope>
|
|
|
- </gml:boundedBy>
|
|
|
- <og:the_geom>
|
|
|
- <gml:MultiSurface srsDimension="2" srsName="http://www.opengis.net/gml/srs/epsg.xml#4326">
|
|
|
- <gml:surfaceMember>
|
|
|
- <gml:Polygon srsDimension="2">
|
|
|
- <gml:exterior>
|
|
|
- <gml:LinearRing srsDimension="2">
|
|
|
- <gml:posList>-103.76667007954185 44.40446480019764 -103.74902136903249 44.40436551670597 -103.74907639625017 44.39448281245848 -103.7666862908511 44.394471734835 -103.76667007954185 44.40446480019764</gml:posList>
|
|
|
- </gml:LinearRing>
|
|
|
- </gml:exterior>
|
|
|
- </gml:Polygon>
|
|
|
- </gml:surfaceMember>
|
|
|
- </gml:MultiSurface>
|
|
|
- </og:the_geom>
|
|
|
- <og:cat>4</og:cat>
|
|
|
- </og:restricted>
|
|
|
+ <?php foreach ($buildingsGml as $kId => $vGml) : ?>
|
|
|
+ <og:restricted gml:id="restricted.<?php echo $kId; ?>">
|
|
|
+ <?php echo $vGml; ?>
|
|
|
+ <og:cat><?php echo $kId; ?></og:cat>
|
|
|
+ </og:restricted>
|
|
|
+ <?php endforeach; ?>
|
|
|
</gml:featureMembers>
|
|
|
</wfs:FeatureCollection>
|
|
|
<?php
|