Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
Mapserver REST API
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Redmine
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Miscellaneous
Mapserver REST API
Commits
f255ac45
Commit
f255ac45
authored
11 years ago
by
Maël Méliani
Browse files
Options
Downloads
Patches
Plain Diff
Moved create_mapfile() in mapfile.py
parent
96bbc92f
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/mapfile.py
+93
-0
93 additions, 0 deletions
src/mapfile.py
src/maptools.py
+0
-123
0 additions, 123 deletions
src/maptools.py
src/server.py
+1
-1
1 addition, 1 deletion
src/server.py
with
94 additions
and
124 deletions
src/mapfile.py
+
93
−
0
View file @
f255ac45
...
@@ -698,6 +698,99 @@ class MapfileWorkspace(Workspace):
...
@@ -698,6 +698,99 @@ class MapfileWorkspace(Workspace):
raise
ValueError
(
"
Bad storage type
'
%s
'
.
"
%
s_type
)
raise
ValueError
(
"
Bad storage type
'
%s
'
.
"
%
s_type
)
def
create_mapfile
(
path
,
map_name
,
data
):
if
os
.
path
.
exists
(
"
%s.map
"
%
path
):
raise
KeyExists
(
map_name
)
mf
=
mapscript
.
mapObj
()
mf
.
name
=
map_name
# The following could be defined in <mapfile.py>:
mf
.
web
.
metadata
.
set
(
"
ows_name
"
,
map_name
)
mf
.
web
.
metadata
.
set
(
"
ows_title
"
,
data
.
get
(
"
title
"
,
map_name
))
mf
.
web
.
metadata
.
set
(
"
ows_abstract
"
,
data
.
get
(
"
abstract
"
,
""
))
# Set default values:
# It should be configurable to the future.
# mf.web.metadata.set("ows_keywordlist", "")
# mf.web.metadata.set("ows_keywordlist_vocabulary", "")
# + ows_keywordlist_[vocabulary’s name]_items
# mf.web.metadata.set("wms_onlineresource", "")
# mf.web.metadata.set("wfs_onlineresource", "")
# mf.web.metadata.set("wms_service_onlineresource", "")
# mf.web.metadata.set("wfs_service_onlineresource", "")
mf
.
web
.
metadata
.
set
(
"
wms_srs
"
,
"
EPSG:4326
"
)
mf
.
web
.
metadata
.
set
(
"
wfs_srs
"
,
"
EPSG:4326
"
)
mf
.
web
.
metadata
.
set
(
"
wms_bbox_extended
"
,
"
true
"
)
# mf.web.metadata.set("wms_resx", "")
# mf.web.metadata.set("wms_resy", "")
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_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
"
,
"
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", "")
# mf.web.metadata.set("wms_rootlayer_abstract", "")
# mf.web.metadata.set("wms_rootlayer_keywordlist", "")
# mf.web.metadata.set("wms_rootlayer_title", "")
# mf.web.metadata.set("wfs_maxfeatures", "")
# 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
)
mf
.
maxsize
=
4096
mf
.
resolution
=
96
mf
.
imagetype
=
'
png
'
mf
.
imagecolor
.
setRGB
(
255
,
255
,
255
)
mf
.
setProjection
(
"
init=epsg:4326
"
)
mf
.
setExtent
(
-
180
,
-
90
,
180
,
90
)
mf
.
units
=
mapscript
.
MS_DD
mf
.
save
(
"
%s.map
"
%
path
)
class
Mapfile
(
MetadataMixin
):
class
Mapfile
(
MetadataMixin
):
"""
"""
"""
"""
...
...
This diff is collapsed.
Click to expand it.
src/maptools.py
deleted
100644 → 0
+
0
−
123
View file @
96bbc92f
#!/usr/bin/env python2.7
# -*- coding: utf-8 -*-
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# #
# MapServer REST API is a python wrapper around MapServer which #
# allows to manipulate a mapfile in a RESTFul way. It has been #
# developped to match as close as possible the way the GeoServer #
# REST API acts. #
# #
# Copyright (C) 2011-2013 Neogeo Technologies. #
# #
# This file is part of MapServer Rest API. #
# #
# MapServer Rest API is free software: you can redistribute it #
# and/or modify it under the terms of the GNU General Public License #
# as published by the Free Software Foundation, either version 3 of #
# the License, or (at your option) any later version. #
# #
# MapServer Rest API is distributed in the hope that it will be #
# useful, but WITHOUT ANY WARRANTY; without even the implied warranty #
# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU General Public License for more details. #
# #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
from
webapp
import
KeyExists
import
metadata
import
mapscript
import
os.path
def
create_mapfile
(
path
,
map_name
,
data
):
if
os
.
path
.
exists
(
"
%s.map
"
%
path
):
raise
KeyExists
(
map_name
)
mf
=
mapscript
.
mapObj
()
mf
.
name
=
map_name
# The following could be defined in <mapfile.py>:
mf
.
web
.
metadata
.
set
(
"
ows_name
"
,
map_name
)
mf
.
web
.
metadata
.
set
(
"
ows_title
"
,
data
.
get
(
"
title
"
,
map_name
))
mf
.
web
.
metadata
.
set
(
"
ows_abstract
"
,
data
.
get
(
"
abstract
"
,
""
))
# Set default values:
# It should be configurable to the future.
# mf.web.metadata.set("ows_keywordlist", "")
# mf.web.metadata.set("ows_keywordlist_vocabulary", "")
# + ows_keywordlist_[vocabulary’s name]_items
# mf.web.metadata.set("wms_onlineresource", "")
# mf.web.metadata.set("wfs_onlineresource", "")
# mf.web.metadata.set("wms_service_onlineresource", "")
# mf.web.metadata.set("wfs_service_onlineresource", "")
mf
.
web
.
metadata
.
set
(
"
wms_srs
"
,
"
EPSG:4326
"
)
mf
.
web
.
metadata
.
set
(
"
wfs_srs
"
,
"
EPSG:4326
"
)
mf
.
web
.
metadata
.
set
(
"
wms_bbox_extended
"
,
"
true
"
)
# mf.web.metadata.set("wms_resx", "")
# mf.web.metadata.set("wms_resy", "")
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_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
"
,
"
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", "")
# mf.web.metadata.set("wms_rootlayer_abstract", "")
# mf.web.metadata.set("wms_rootlayer_keywordlist", "")
# mf.web.metadata.set("wms_rootlayer_title", "")
# mf.web.metadata.set("wfs_maxfeatures", "")
# 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
)
mf
.
maxsize
=
4096
mf
.
resolution
=
96
mf
.
imagetype
=
'
png
'
mf
.
imagecolor
.
setRGB
(
255
,
255
,
255
)
mf
.
setProjection
(
"
init=epsg:4326
"
)
mf
.
setExtent
(
-
180
,
-
90
,
180
,
90
)
mf
.
units
=
mapscript
.
MS_DD
mf
.
save
(
"
%s.map
"
%
path
)
This diff is collapsed.
Click to expand it.
src/server.py
+
1
−
1
View file @
f255ac45
...
@@ -79,7 +79,7 @@ class mapfiles(object):
...
@@ -79,7 +79,7 @@ class mapfiles(object):
path
=
tools
.
mk_mapfile_path
(
map_name
)
path
=
tools
.
mk_mapfile_path
(
map_name
)
with
webapp
.
mightConflict
(
message
=
"
Mapfile
'
{exception}
'
already exists.
"
):
with
webapp
.
mightConflict
(
message
=
"
Mapfile
'
{exception}
'
already exists.
"
):
map
tools
.
create_mapfile
(
path
,
map_name
,
data
)
map
file
.
create_mapfile
(
path
,
map_name
,
data
)
webapp
.
Created
(
"
%s/maps/%s%s
"
%
(
web
.
ctx
.
home
,
map_name
,
(
"
.%s
"
%
format
)
if
format
else
""
))
webapp
.
Created
(
"
%s/maps/%s%s
"
%
(
web
.
ctx
.
home
,
map_name
,
(
"
.%s
"
%
format
)
if
format
else
""
))
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment