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
5fd51896
Commit
5fd51896
authored
11 years ago
by
Maël Méliani
Browse files
Options
Downloads
Patches
Plain Diff
Changed method to get projection from a featureType or a coverage. To develop...
parent
976f89a5
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
src/mapfile.py
+9
-0
9 additions, 0 deletions
src/mapfile.py
src/server.py
+9
-7
9 additions, 7 deletions
src/server.py
src/stores.py
+1
-3
1 addition, 3 deletions
src/stores.py
src/tools.py
+23
-0
23 additions, 0 deletions
src/tools.py
with
42 additions
and
10 deletions
src/mapfile.py
+
9
−
0
View file @
5fd51896
...
...
@@ -301,6 +301,15 @@ class LayerModel(MetadataMixin):
mapscript
.
projectionObj
(
'
+init=epsg:4326
'
))
return
stores
.
Extent
(
rect
.
minx
,
rect
.
miny
,
rect
.
maxx
,
rect
.
maxy
)
def
get_proj4
(
self
):
return
self
.
ms
.
getProjection
()
def
get_wkt
(
self
):
return
tools
.
proj4_to_wkt
(
self
.
ms
.
getProjection
())
def
get_authority
(
self
):
return
tools
.
wkt_to_authority
(
self
.
get_wkt
())
class
FeatureTypeModel
(
LayerModel
):
"""
...
...
This diff is collapsed.
Click to expand it.
src/server.py
+
9
−
7
View file @
5fd51896
...
...
@@ -250,8 +250,8 @@ class featuretype(object):
"
title
"
:
ft
.
get_mra_metadata
(
"
title
"
,
ft
.
name
),
"
abstract
"
:
ft
.
get_mra_metadata
(
"
abstract
"
,
None
),
"
keywords
"
:
ft
.
get_mra_metadata
(
"
keywords
"
,
[]),
"
srs
"
:
dsft
.
get_projection
(
),
"
nativeCRS
"
:
ds
ft
.
get_
native
(),
"
srs
"
:
"
%s:%s
"
%
(
ft
.
get_authority
()[
0
],
ft
.
get_authority
()[
1
]
),
"
nativeCRS
"
:
ft
.
get_
wkt
(),
"
attributes
"
:
[{
"
name
"
:
f
.
get_name
(),
"
minOccurs
"
:
0
if
f
.
is_nullable
()
else
1
,
...
...
@@ -405,14 +405,15 @@ class coverage(object):
@HTTPCompatible
()
def
GET
(
self
,
map_name
,
ws_name
,
cs_name
,
c_name
,
format
):
mf
,
ws
=
get_mapfile_workspace
(
map_name
,
ws_name
)
# with webapp.mightNotFound("coveragestore", workspace=ws_name):
# cs = ws.get_coveragestore(cs_name)
with
webapp
.
mightNotFound
(
"
coverage
"
,
coveragestore
=
cs_name
):
c
=
ws
.
get_coveragemodel
(
c_name
,
cs_name
)
with
webapp
.
mightNotFound
(
"
coveragestore
"
,
workspace
=
ws_name
):
cs
=
ws
.
get_coveragestore
(
cs_name
)
extent
=
c
.
get_extent
()
latlon_extent
=
c
s
.
get_latlon_extent
()
latlon_extent
=
c
.
get_latlon_extent
()
return
{
"
coverage
"
:
({
"
name
"
:
c
.
name
,
...
...
@@ -424,7 +425,8 @@ class coverage(object):
"
title
"
:
c
.
get_mra_metadata
(
"
title
"
,
c
.
name
),
"
abstract
"
:
c
.
get_mra_metadata
(
"
abstract
"
,
None
),
"
keywords
"
:
c
.
get_mra_metadata
(
"
keywords
"
,
[]),
"
srs
"
:
cs
.
get_projection
(),
"
srs
"
:
"
%s:%s
"
%
(
c
.
get_authority
()[
0
],
c
.
get_authority
()[
1
]),
"
nativeCRS
"
:
c
.
get_wkt
(),
"
nativeBoundingBox
"
:
{
"
minx
"
:
extent
.
minX
(),
"
miny
"
:
extent
.
minY
(),
...
...
This diff is collapsed.
Click to expand it.
src/stores.py
+
1
−
3
View file @
5fd51896
...
...
@@ -404,9 +404,7 @@ class Coveragestore(object):
return
self
.
backend
.
GetProjection
()
def
get_proj4
(
self
):
proj
=
osr
.
SpatialReference
()
proj
.
ImportFromWkt
(
self
.
get_projection
())
return
proj
.
ExportToProj4
()
return
tools
.
wkt_to_proj4
(
self
.
get_projection
())
def
nbbands
(
self
):
return
self
.
backend
.
RasterCount
...
...
This diff is collapsed.
Click to expand it.
src/tools.py
+
23
−
0
View file @
5fd51896
...
...
@@ -34,6 +34,7 @@ import pyxml
import
webapp
import
xml.etree.ElementTree
as
etree
from
osgeo
import
osr
__config
=
None
...
...
@@ -156,4 +157,26 @@ def is_hidden(path):
# MacOSX has at least four ways to hide files...
return
os
.
path
.
basename
(
path
).
startswith
(
"
.
"
)
def
wkt_to_proj4
(
wkt
):
srs
=
osr
.
SpatialReference
()
srs
.
ImportFromWkt
(
wkt
)
return
srs
.
ExportToProj4
()
def
proj4_to_wkt
(
proj4
):
srs
=
osr
.
SpatialReference
()
srs
.
ImportFromProj4
(
proj4
)
return
srs
.
ExportToWkt
()
def
wkt_to_authority
(
wkt
):
srs
=
osr
.
SpatialReference
()
srs
.
ImportFromWkt
(
wkt
)
# Are there really no other with osgeo? Oo
if
srs
.
GetAuthorityCode
(
'
PROJCS
'
)
==
None
and
srs
.
GetAuthorityCode
(
'
GEOGCS
'
)
!=
None
:
return
srs
.
GetAuthorityName
(
'
GEOGCS
'
),
srs
.
GetAuthorityCode
(
'
GEOGCS
'
)
if
srs
.
GetAuthorityCode
(
'
PROJCS
'
)
!=
None
:
return
srs
.
GetAuthorityName
(
'
PROJCS
'
),
srs
.
GetAuthorityCode
(
'
PROJCS
'
)
else
:
raise
KeyError
(
"
Unable to get authority from %s
"
%
wkt
)
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