Skip to content

Commit

Permalink
get geometry type for layers
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmednoureldeen committed Apr 11, 2018
1 parent e6e1aa7 commit aad557f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions geonode/api/resourcebase_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -748,6 +748,8 @@ def format_objects(self, objects):
if obj.storeType == 'remoteStore' and hasattr(obj, 'remote_service'):
formatted_obj['online'] = (obj.remote_service.probe == 200)

formatted_obj['gtype'] = self.dehydrate_gtype(bundle)

# put the object on the response stack
formatted_objects.append(formatted_obj)
return formatted_objects
Expand All @@ -770,6 +772,9 @@ def dehydrate_links(self, bundle):

return dehydrated

def dehydrate_gtype(self, bundle):
return bundle.obj.gtype

def populate_object(self, obj):
"""Populate results with necessary fields
Expand Down
6 changes: 6 additions & 0 deletions geonode/layers/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,12 @@ def service_typename(self):
def attributes(self):
return self.attribute_set.exclude(attribute='the_geom').order_by('display_order')

# layer geometry type.
@property
def gtype(self):
# return attribute type without 'gml:' and 'PropertyType'
return self.attribute_set.get(attribute='the_geom').attribute_type[4:-12]

def get_base_file(self):
"""Get the shp or geotiff file for this layer.
"""
Expand Down

0 comments on commit aad557f

Please sign in to comment.