[fusion-commits] r2250 - in trunk/layers: . MapServer/php
svn_fusion at osgeo.org
svn_fusion at osgeo.org
Tue Oct 19 10:47:01 EDT 2010
Author: pagameba
Date: 2010-10-19 07:47:00 -0700 (Tue, 19 Oct 2010)
New Revision: 2250
Modified:
trunk/layers/Layers.js
trunk/layers/MapServer/php/LoadMap.php
Log:
adding metadata support for WFS connections on layers in mapserver
Modified: trunk/layers/Layers.js
===================================================================
--- trunk/layers/Layers.js 2010-10-19 14:31:05 UTC (rev 2249)
+++ trunk/layers/Layers.js 2010-10-19 14:47:00 UTC (rev 2250)
@@ -575,8 +575,77 @@
this.isEditing = false;
this.oMap.triggerEvent(Fusion.Event.LAYER_STOP_EDIT, this);
}
+ },
+
+ hasWFSConnection: function() {
+ return this.metadata['wfs_onlineresource'] != undefined &&
+ this.metadata.wfs_onlineresource != '';
+ },
+
+ getWFSConnection: function(callback) {
+ var that = this;
+ if (this.hasWFSConnection()) {
+ if (!this.wfsConnection) {
+ var version = this.metadata['wfs_version'] || '1.1.0';
+ var typeName = this.metadata['wfs_typename'] || this.name;
+
+ OpenLayers.Request.GET({
+ url: this.metadata.wfs_onlineresource,
+ params: {
+ service: 'WFS',
+ version: version,
+ request: 'GetCapabilities'
+ },
+ callback: function(gc_response) {
+ var gc_parser = new OpenLayers.Format.WFSCapabilities();
+ var capabilities = gc_parser.read(gc_response.responseText);
+ console.dir(capabilities);
+ OpenLayers.Request.GET({
+ url: this.metadata.wfs_onlineresource,
+ params: {
+ service: 'WFS',
+ version: version,
+ request: 'DescribeFeatureType',
+ typename: typeName
+ },
+ callback: function(dft_response) {
+ if (dft_response.status == 200) {
+ var dft_parser = new OpenLayers.Format.WFSDescribeFeatureType();
+ console.dir(dft_response);
+ var xml = dft_parser.read(dft_response.responseText);
+ console.dir(xml);
+ if (xml.featureTypes.length) {
+ var props = xml.featureTypes[0].properties;
+ that.metadata.wfs_properties = props;
+ if (!that.metadata['wfs_geometry']) {
+ for (var i=0; i<props.length; i++) {
+ var prop = props[i];
+ if (prop.localType == 'GeometryPropertyType') {
+ that.metadata.wfs_geometry = prop.name;
+ that.metadata.wfs_geometrytype = prop.type;
+ break;
+ }
+ }
+ }
+ }
+ }
+ if (callback) {
+ callback.apply(null, [conn]);
+ }
+ }
+ });
+ }
+ });
+
+ // this.wfsConnection = new OpenLayers.Protocol.WFS({
+ // version: version,
+ // featureType: typeName
+ // });
+ }
+ } else if (callback) {
+ callback.apply(null, [this.wfsConnection]);
+ }
}
-
});
/***************************************************************************
Modified: trunk/layers/MapServer/php/LoadMap.php
===================================================================
--- trunk/layers/MapServer/php/LoadMap.php 2010-10-19 14:31:05 UTC (rev 2249)
+++ trunk/layers/MapServer/php/LoadMap.php 2010-10-19 14:47:00 UTC (rev 2250)
@@ -209,6 +209,15 @@
$layer->set("name",replaceInvalidLayerName($layer->name));
$layerObj->metadata = NULL;
+ $wfs_onlineresource = $layer->getMetadata('wfs_onlineresource');
+ if ($wfs_onlineresource != '') {
+ $layerObj->metadata->wfs_onlineresource = $wfs_onlineresource;
+ $wfs_typename = $layer->getMetadata('wfs_typename');
+ $layerObj->metadata->wfs_typename = $wfs_typename != '' ? $wfs_typename : $layer->name;
+ $wfs_version = $layer->getMetadata('wfs_version');
+ $layerObj->metadata->wfs_version = $wfs_version != '' ? $wfs_version : '1.1.0';
+ }
+
if (isset($_REQUEST['layer_metadata'])) {
$layerMetadataKeys = explode(',',$_REQUEST['layer_metadata']);
foreach($layerMetadataKeys as $key) {
More information about the fusion-commits
mailing list