~chamindra/sahana-eden/frp3

« back to all changes in this revision

Viewing changes to views/gis/ol_layers_features2.py

  • Committer: nursix.org
  • Date: 2010-02-15 00:36:02 UTC
  • mfrom: (609.1.1 frp)
  • Revision ID: dominic@nursix.org-20100215003602-22zwuwsifq47tn2l
Merge chamindra: Feature Class => Location Type

Show diffs side-by-side

added added

removed removed

Lines of Context:
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:}}
6
 
        coords = 
 
6
        coords =
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)));
10
10
    {{pass}}
11
 
    
 
11
 
12
12
    # Bit of a hacky way to do it. Especially the transform...
13
13
    coordinates = shn_gis_coord_decode(feature['f_coords'])
14
14
    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";
17
17
    else:
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), ";
22
22
         if(ctot > 0):
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)";   
24
 
         coords += ");\n"            
 
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)";
 
24
         coords += ");\n"
25
25
 
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) )
60
60
    return output
61
 
   
62
 
   
 
61
 
 
62
 
63
63
def shn_gis_form_popupHTML_view(feature):
64
64
    "Generate vars for popup HTML content"
65
 
        
 
65
 
66
66
    # Set Feature uuid
67
67
    if(isset(feature['f_uuid']) && feature['f_uuid'] != ''):
68
68
        feature_uuid = feature['f_uuid']
69
69
    else:
70
70
        # :(
71
71
        feature_uuid = 'popup_' . id++
72
 
    
 
72
 
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'])
76
76
    else:
77
77
        feature_class = shn_gis_get_feature_class_uuid(conf['gis_feature_type_default'])
78
 
    
 
78
 
79
79
    # Set name.
80
80
    if(isset(feature['f_name']) && feature['f_name'] != ''):
81
81
        name = feature['f_name']
82
82
    else:
83
83
        name = feature_class['c_name']
84
 
    
 
84
 
85
85
    # Set Description
86
86
    if(isset(feature['f_description']) && feature['f_description'] != ''):
87
87
        description = feature['f_description']
88
88
    else:
89
89
        description = feature_class['c_description']
90
 
    
 
90
 
91
91
    # Set Author
92
92
    if(isset(feature['f_author']) && feature['f_author'] != ''):
93
93
        author = feature['f_author']
94
94
    else:
95
95
        author = 'Anonymous'
96
 
    
 
96
 
97
97
    # Set Address
98
98
    if(isset(feature['f_address']) && feature['f_address'] != ''):
99
99
        address = feature['f_address']
100
100
    else:
101
101
        address = false
102
 
    
 
102
 
103
103
    # Set Event Date
104
104
    if(isset(feature['f_event_date'])):
105
105
        event_date = feature['f_event_date']
106
106
    else:
107
107
        event_date = 'Unknown'
108
 
    
 
108
 
109
109
    # Set View URL
110
110
    if(isset(feature['f_url']) && feature['f_url'] != ''):
111
111
        url = feature['f_url']
112
112
    else:
113
113
        url = false
114
 
    
 
114
 
115
115
    # Set View URL
116
116
    if(isset(feature['f_url_view']) && feature['f_url_view'] != ''):
117
117
        url_view = feature['f_url_view']
118
118
    else:
119
119
        url_view = false
120
 
    
 
120
 
121
121
    # Set Edit URL
122
122
    if (isset(feature['f_url_edit']) && feature['f_url_edit'] != ''):
123
123
        # if feature has an edit url
131
131
    else:
132
132
        # if feature is not module related and has a uuid to tie changes to. (can edit)
133
133
        url_edit = true
134
 
    
 
134
 
135
135
    # Set Delete URL
136
136
    if (isset(feature['f_url_delete']) && feature['f_url_delete'] != ''):
137
137
        # if feature has a delete url
145
145
    else:
146
146
        # if feature is not module related and has a uuid to tie changes to. (can del)
147
147
        url_del = true
148
 
 
 
 
b'\\ No newline at end of file'