1
ol_layers_features.js old:
1
ol_layers_features.js old:
2
2
{{if feature.type==feature_1:}}
3
3
var geom = new OpenLayers.Geometry.Point((new OpenLayers.LonLat({{=feature.lon}}, {{=feature.lat}}).transform(proj4326, proj_current)).lon, (new OpenLayers.LonLat({{=feature.lon}}, {{=feature.lat}}).transform(proj4326, proj_current)).lat));
4
4
//ToDo: make work for more than just points!
5
5
{{elif feature.feature_type==2:}}
7
7
var geom = new OpenLayers.Geometry.LineString(coords);
8
8
{{elif feature.feature_type==3:}}
9
9
var geom = new OpenLayers.Geometry.Polygon(new Array(new OpenLayers.Geometry.LinearRing(coords)));
12
12
# Bit of a hacky way to do it. Especially the transform...
13
13
coordinates = shn_gis_coord_decode(feature['f_coords'])
15
15
if(count(coordinates) == 1):
16
coords += "var coords = new Array(new OpenLayers.Geometry.Point((new OpenLayers.LonLat({coordinates[i][0]}, {coordinates[i][1]}).transform(proj4326, proj_current)).lon, (new OpenLayers.LonLat({coordinates[i][0]}, {coordinates[i][1]}).transform(proj4326, proj_current)).lat));\n";
16
coords += "var coords = new Array(new OpenLayers.Geometry.Point((new OpenLayers.LonLat({coordinates[i][0]}, {coordinates[i][1]}).transform(proj4326, proj_current)).lon, (new OpenLayers.LonLat({coordinates[i][0]}, {coordinates[i][1]}).transform(proj4326, proj_current)).lat));\n";
18
18
coords += "var coords = new Array(";
19
19
ctot = count(coordinates) - 1;
20
20
for(i = 1; i < ctot; i++):
21
21
coords += "new OpenLayers.Geometry.Point((new OpenLayers.LonLat({coordinates[i][0]}, {coordinates[i][1]}).transform(proj4326, proj_current)).lon, (new OpenLayers.LonLat({coordinates[i][0]}, {coordinates[i][1]}).transform(proj4326, proj_current)).lat), ";
23
coords += "new OpenLayers.Geometry.Point((new OpenLayers.LonLat({coordinates[i][0]}, {coordinates[i][1]}).transform(proj4326, proj_current)).lon, (new OpenLayers.LonLat({coordinates[i][0]}, {coordinates[i][1]}).transform(proj4326, proj_current)).lat)";
23
coords += "new OpenLayers.Geometry.Point((new OpenLayers.LonLat({coordinates[i][0]}, {coordinates[i][1]}).transform(proj4326, proj_current)).lon, (new OpenLayers.LonLat({coordinates[i][0]}, {coordinates[i][1]}).transform(proj4326, proj_current)).lat)";
26
# Rewrite in JavaScript: http://javascript.about.com/library/bltut21.htm
26
# Rewrite in JavaScript: http://javascript.about.com/library/bltut21.htm
27
27
def shn_gis_coord_decode(coords):
28
28
""" Takes the coord string stored in the db and decodes it into an array of:
29
29
[0 => center of obj][0 => x, 1 => y, 2 => z]
58
58
foreach(wkt as point):
59
59
array_push(output, explode(' ' , point, 3) )
63
63
def shn_gis_form_popupHTML_view(feature):
64
64
"Generate vars for popup HTML content"
67
67
if(isset(feature['f_uuid']) && feature['f_uuid'] != ''):
68
68
feature_uuid = feature['f_uuid']
71
71
feature_uuid = 'popup_' . id++
73
73
# Set Feature Class
74
74
if(isset(feature['f_class']) && feature['f_class'] != ''):
75
75
feature_class = shn_gis_get_feature_class_uuid(feature['f_class'])
77
77
feature_class = shn_gis_get_feature_class_uuid(conf['gis_feature_type_default'])
80
80
if(isset(feature['f_name']) && feature['f_name'] != ''):
81
81
name = feature['f_name']
83
83
name = feature_class['c_name']
86
86
if(isset(feature['f_description']) && feature['f_description'] != ''):
87
87
description = feature['f_description']
89
89
description = feature_class['c_description']
92
92
if(isset(feature['f_author']) && feature['f_author'] != ''):
93
93
author = feature['f_author']
95
95
author = 'Anonymous'
98
98
if(isset(feature['f_address']) && feature['f_address'] != ''):
99
99
address = feature['f_address']
104
104
if(isset(feature['f_event_date'])):
105
105
event_date = feature['f_event_date']
107
107
event_date = 'Unknown'
110
110
if(isset(feature['f_url']) && feature['f_url'] != ''):
111
111
url = feature['f_url']
116
116
if(isset(feature['f_url_view']) && feature['f_url_view'] != ''):
117
117
url_view = feature['f_url_view']
122
122
if (isset(feature['f_url_edit']) && feature['f_url_edit'] != ''):
123
123
# if feature has an edit url