diff --git a/src/mapfile.py b/src/mapfile.py index edd15d8c0badde4fae50352e17a8017c842c5079..dbe4ecf490c1e9c25999c240b15f0f8f373c4029 100644 --- a/src/mapfile.py +++ b/src/mapfile.py @@ -81,7 +81,7 @@ class Layer(MetadataMixin): def enable(self, enabled=True): requests = ["GetCapabilities", "GetMap", "GetFeatureInfo", "GetLegendGraphic"] self.ms.status = mapscript.MS_ON if enabled else mapscript.MS_OFF - self.set_metadata("wms_enable_request", " ".join(('%s' if enabled else "!%s") % c for c in requests)) + self.set_metadata("wms_enable_request", " ".join(('%s' if enabled else "!%s") % c for c in requests)) def get_type_name(self): return { @@ -349,7 +349,8 @@ class FeatureTypeModel(LayerModel): }) if enabled: - layer.set_metadata("wfs_enable_request", "GetCapabilities GetFeature DescribeFeatureType") + layer.set_metadata("wfs_enable_request", + "GetCapabilities GetFeature DescribeFeatureType") # Configure the layer based on information from the store. ds = ws.get_datastore(self.get_mra_metadata("storage")) @@ -365,17 +366,24 @@ class FeatureTypeModel(LayerModel): }) field_names.append(field.get_name()) + geometry_column = ft.get_geometry_column() + if geometry_column == None: + geometry_column = "geometry" layer.set_metadatas({ - "wfs_include_items": ",".join(field_names), + "ows_include_items": ",".join(field_names), "gml_include_items": ",".join(field_names), - "wfs_featureid": ft.get_fid_column(), - "gml_featureid": ft.get_fid_column(), - "gml_geometries": ft.get_geometry_column(), - "gml_%s_type" % ft.get_geometry_column(): ft.get_geomtype_gml(), + "gml_geometries": geometry_column, + "gml_%s_type" % geometry_column: ft.get_geomtype_gml(), # TODO: Add gml_<geometry name>_occurances, "wfs_srs": "EPSG:4326", "wfs_getfeature_formatlist": "OGRGML,SHAPEZIP", }) + + if ft.get_fid_column() != None: + layer.set_metadatas({ + "wfs_featureid": ft.get_fid_column(), + "gml_featureid": ft.get_fid_column(), + }) plugins.extend("post_configure_vector_layer", self, ws, ds, ft, layer) @@ -776,46 +784,33 @@ class Mapfile(MetadataMixin): # We still clone, because we have to start from something, # but everything should be configured() anyway. layer = Layer(model.ms.clone()) - layer.ms.name = l_name - layer.ms.dump = mapscript.MS_TRUE - layer.ms.tolerance = 6 - layer.ms.toleranceunits = mapscript.MS_PIXELS - layer.ms.template = "foo.html" + self.ms.insertLayer(layer.ms) + layer.ms.name = l_name layer.enable(l_enabled) - self.ms.insertLayer(layer.ms) + + # is queryable (by default): + layer.ms.template = "foo.html" # TODO: Support html format response l_metadata["wms_name"] = l_name + l_metadata.setdefault("wms_title", l_name) l_metadata.setdefault("wms_abstract", l_name) l_metadata.setdefault("wms_bbox_extended", "true") - # TODO: Add other default values as above: - # "wms_keywordlist" - # "wms_keywordlist_vocabulary" - # "wms_keywordlist_<vocabulary>_items" - # "wms_srs" - # "wms_dataurl_format" - # "wms_dataurl_href" - # "wms_getmap_formatlist" - # "wms_getfeatureinfo_formatlist" - # "wms_getlegendgraphic_formatlist" - # "ows_attribution_title" - # "ows_attribution_onlineresource": "" - # "ows_attribution_logourl_href" - # "ows_attribution_logourl_format" - # "ows_attribution_logourl_height" - # "ows_attribution_logourl_width" - # "ows_identifier_authority" - # "ows_identifier_value" - # "ows_authorityurl_name" - # "ows_authorityurl_href" - # "ows_metadataurl_type" - # "ows_metadataurl_href" - # "ows_metadataurl_format" + # wms_keywordlist, wms_keywordlist_vocabulary + # wms_keywordlist_<vocabulary>_items + # wms_srs + # wms_dataurl_(format|href) + # ows_attribution_(title|onlineresource) + # ows_attribution_logourl_(href|format|height|width) + # ows_identifier_(authority|value) + # ows_authorityurl_(name|href) + # ows_metadataurl_(type|href|format) # TODO: pass correct data (title, abstract, ...) to layer.update() layer.update(l_metadata) + model.configure_layer(ws, layer, l_enabled) # TODO: Check if class already exists. @@ -848,7 +843,6 @@ class Mapfile(MetadataMixin): </UserStyle> \ </NamedLayer> \ </StyledLayerDescriptor>' - elif layer.ms.type == mapscript.MS_LAYER_LINE: # TODO: move this sld in external files s_name = 'default_line' @@ -872,7 +866,6 @@ class Mapfile(MetadataMixin): </UserStyle> \ </NamedLayer> \ </StyledLayerDescriptor>' - elif layer.ms.type == mapscript.MS_LAYER_POLYGON: # TODO: move this sld in external files s_name = 'default_polygon' @@ -899,9 +892,7 @@ class Mapfile(MetadataMixin): </UserStyle> \ </NamedLayer> \ </StyledLayerDescriptor>' - layer.add_style_sld(self, s_name, style) - return layer def delete_layer(self, l_name): layer = self.get_layer(l_name) @@ -944,7 +935,6 @@ class Mapfile(MetadataMixin): with self.mra_metadata("layergroups", {}) as layergroups: del layergroups[lg_name] - # Styles: def iter_styles(self): diff --git a/src/maptools.py b/src/maptools.py index 647fedd903c53c9ff26c3ae7bb2784cda0a6078b..23b5e0ea24456d89bb0beafe09a2761ee9c0e285 100644 --- a/src/maptools.py +++ b/src/maptools.py @@ -58,39 +58,47 @@ def create_mapfile(path, map_name, data): mf.web.metadata.set("wms_bbox_extended", "true") # mf.web.metadata.set("wms_resx", "") # mf.web.metadata.set("wms_resy", "") - mf.web.metadata.set("wms_enable_request", "GetCapabilities !GetMap !GetFeatureInfo !GetLegendGraphic") - mf.web.metadata.set("wfs_enable_request", "GetCapabilities !DescribeFeatureType !GetFeature") - mf.web.metadata.set("ows_sld_enabled", "true") - # mf.web.metadata.set("ows_schemas_location", "") - # mf.web.metadata.set("ows_updatesequence", "") - # mf.web.metadata.set("ows_addresstype", "") - # mf.web.metadata.set("ows_address", "") - # mf.web.metadata.set("ows_city", "") - # mf.web.metadata.set("ows_stateorprovince", "") - # mf.web.metadata.set("ows_postcode", "") - # mf.web.metadata.set("ows_contactperson", "") - # mf.web.metadata.set("ows_contactposition", "") - # mf.web.metadata.set("ows_contactorganization", "") - # mf.web.metadata.set("ows_contactelectronicmailaddress", "") - # mf.web.metadata.set("ows_contactfacsimiletelephone", "") - # mf.web.metadata.set("ows_contactvoicetelephone, "")" - # mf.web.metadata.set("wms_fees", "") - # mf.web.metadata.set("wfs_fees", "") - # mf.web.metadata.set("wms_accessconstraints", "") - # mf.web.metadata.set("wfs_accessconstraints", "") + + mf.web.metadata.set("ows_schemas_location", + "http://schemas.opengeospatial.net") + mf.web.metadata.set("ows_updatesequence", "foo") + mf.web.metadata.set("ows_addresstype", "foo") + mf.web.metadata.set("ows_address", "foo") + mf.web.metadata.set("ows_city", "foo") + mf.web.metadata.set("ows_stateorprovince", "foo") + mf.web.metadata.set("ows_postcode", "foo") + mf.web.metadata.set("ows_contactperson", "foo") + mf.web.metadata.set("ows_contactposition", "foo") + mf.web.metadata.set("ows_contactorganization", "foo") + mf.web.metadata.set("ows_contactelectronicmailaddress", "foo") + mf.web.metadata.set("ows_contactfacsimiletelephone", "foo") + mf.web.metadata.set("ows_contactvoicetelephone", "foo") + mf.web.metadata.set("wms_fees", "none") + mf.web.metadata.set("wfs_fees", "none") + mf.web.metadata.set("wms_accessconstraints", "none") + mf.web.metadata.set("wfs_accessconstraints", "none") # mf.web.metadata.set("ows_attribution_logourl_format", "") # mf.web.metadata.set("ows_attribution_logourl_height", "") # mf.web.metadata.set("ows_attribution_logourl_href", "") # mf.web.metadata.set("ows_attribution_logourl_width", "") # mf.web.metadata.set("ows_attribution_onlineresource", "") # mf.web.metadata.set("ows_attribution_title", "") - mf.web.metadata.set("wms_encoding", "UTF-8") - mf.web.metadata.set("wfs_encoding", "UTF-8") - # mf.web.metadata.set("wms_getcapabilities_version", "") - # mf.web.metadata.set("wfs_getcapabilities_version", "") + + mf.web.metadata.set("wms_enable_request", + "GetCapabilities GetMap GetFeatureInfo GetLegendGraphic") + mf.web.metadata.set("wfs_enable_request", + "GetCapabilities DescribeFeatureType GetFeature") + mf.web.metadata.set("ows_sld_enabled", "true") + mf.web.metadata.set("wms_getcapabilities_version", "1.3.0") + mf.web.metadata.set("wfs_getcapabilities_version", "1.0.0") # mf.web.metadata.set("wms_getmap_formatlist", "") # mf.web.metadata.set("wms_getlegendgraphic_formatlist", "") - # mf.web.metadata.set("wms_feature_info_mime_type", "") + mf.web.metadata.set("wms_feature_info_mime_type", + "application/vnd.ogc.gml,text/plain") + # TODO: text/html + mf.web.metadata.set("wms_encoding", "UTF-8") + mf.web.metadata.set("wfs_encoding", "UTF-8") + # mf.web.metadata.set("wms_timeformat", "") # mf.web.metadata.set("wms_languages", "") # mf.web.metadata.set("wms_layerlimit", "") @@ -101,7 +109,6 @@ def create_mapfile(path, map_name, data): # mf.web.metadata.set("wfs_feature_collection", "") # mf.web.metadata.set("wfs_namespace_uri", "") # mf.web.metadata.set("wfs_namespace_prefix", "") - # ... mf.status = mapscript.MS_ON mf.setSize(256,256) @@ -114,4 +121,3 @@ def create_mapfile(path, map_name, data): mf.units = mapscript.MS_DD mf.save("%s.map" % path) - diff --git a/src/stores.py b/src/stores.py index d4a74909c1812a937411b3c940fd90e6e25b232a..4dffa892b22f19d2a9503a4108c1b81631b759f5 100644 --- a/src/stores.py +++ b/src/stores.py @@ -167,9 +167,13 @@ class Featuretype(object): return self.backend.GetName() def get_fid_column(self): + if self.backend.GetFIDColumn() == "": + return None return self.backend.GetFIDColumn() def get_geometry_column(self): + if self.backend.GetGeometryColumn() == "": + return None return self.backend.GetGeometryColumn() def get_extent(self):