equal
deleted
inserted
replaced
14 |
14 |
15 |
15 |
16 # import standard library |
16 # import standard library |
17 |
17 |
18 # import interfaces |
18 # import interfaces |
19 from pyams_gis.interfaces.layer import IMapLayer, IBaseTileMapLayer, ITileMapLayer, IWMSMapLayer, IGeoportalMapLayer, \ |
19 import json |
|
20 |
|
21 from pyams_gis.interfaces.layer import IGeoJSONLayer, IMapLayer, IBaseTileMapLayer, ITileMapLayer, \ |
|
22 IWMSMapLayer, IGeoportalMapLayer, \ |
20 IEsriFeatureMapLayer, IGoogleMapLayer |
23 IEsriFeatureMapLayer, IGoogleMapLayer |
21 from pyams_i18n.interfaces import II18n |
24 from pyams_i18n.interfaces import II18n |
22 |
25 |
23 # import packages |
26 # import packages |
24 from persistent import Persistent |
27 from persistent import Persistent |
44 min_zoom = FieldProperty(IMapLayer['min_zoom']) |
47 min_zoom = FieldProperty(IMapLayer['min_zoom']) |
45 max_zoom = FieldProperty(IMapLayer['max_zoom']) |
48 max_zoom = FieldProperty(IMapLayer['max_zoom']) |
46 |
49 |
47 def get_configuration(self): |
50 def get_configuration(self): |
48 """Get configuration mapping""" |
51 """Get configuration mapping""" |
49 result = {'name': self.name, |
52 result = { |
50 'title': II18n(self).query_attribute('title')} |
53 'name': self.name, |
|
54 'title': II18n(self).query_attribute('title') |
|
55 } |
51 update_dict(result, 'factory', self.factory) |
56 update_dict(result, 'factory', self.factory) |
52 update_dict(result, 'minZoom', self.min_zoom) |
57 update_dict(result, 'minZoom', self.min_zoom) |
53 update_dict(result, 'maxZoom', self.max_zoom) |
58 update_dict(result, 'maxZoom', self.max_zoom) |
54 if self.depends: |
59 if self.depends: |
55 depends = {} |
60 depends = {} |
57 depends[name] = get_resource_path(resource) |
62 depends[name] = get_resource_path(resource) |
58 update_dict(result, 'dependsOn', depends) |
63 update_dict(result, 'dependsOn', depends) |
59 return result |
64 return result |
60 |
65 |
61 |
66 |
|
67 class GeoJSONLayer(MapLayer): |
|
68 """GeoJSON layer""" |
|
69 |
|
70 factory = 'PyAMS_GIS.factory.GeoJSON' |
|
71 layer_type = _("GeoJSON") |
|
72 |
|
73 url = FieldProperty(IGeoJSONLayer['url']) |
|
74 style = FieldProperty(IGeoJSONLayer['style']) |
|
75 |
|
76 def get_configuration(self): |
|
77 result = super(GeoJSONLayer, self).get_configuration() |
|
78 update_dict(result, 'url', self.url) |
|
79 if self.style: |
|
80 update_dict(result, 'style', json.loads(self.style)) |
|
81 return result |
|
82 |
|
83 |
62 class BaseTileMapLayer(MapLayer): |
84 class BaseTileMapLayer(MapLayer): |
63 """Base tile map layer""" |
85 """Base tile map layer""" |
64 |
86 |
65 attribution = FieldProperty(IBaseTileMapLayer['attribution']) |
87 attribution = FieldProperty(IBaseTileMapLayer['attribution']) |
66 bounds = FieldProperty(IBaseTileMapLayer['bounds']) |
88 bounds = FieldProperty(IBaseTileMapLayer['bounds']) |
68 def get_configuration(self): |
90 def get_configuration(self): |
69 result = super(BaseTileMapLayer, self).get_configuration() |
91 result = super(BaseTileMapLayer, self).get_configuration() |
70 update_dict(result, 'attribution', self.attribution) |
92 update_dict(result, 'attribution', self.attribution) |
71 if self.bounds: |
93 if self.bounds: |
72 point1, point2 = self.bounds.wgs_coordinates |
94 point1, point2 = self.bounds.wgs_coordinates |
73 result['bounds'] = [{'lat': float(point1[1]), |
95 result['bounds'] = [{ |
74 'lon': float(point1[0])}, |
96 'lat': float(point1[1]), |
75 {'lat': float(point2[1]), |
97 'lon': float(point1[0]) |
76 'lon': float(point2[0])}] |
98 }, { |
|
99 'lat': float(point2[1]), |
|
100 'lon': float(point2[0]) |
|
101 }] |
77 return result |
102 return result |
78 |
103 |
79 |
104 |
80 @implementer(ITileMapLayer) |
105 @implementer(ITileMapLayer) |
81 class TileMapLayer(BaseTileMapLayer): |
106 class TileMapLayer(BaseTileMapLayer): |