Ignore:
Timestamp:
Apr 4, 2020, 5:59:29 PM (7 years ago)
Author:
Joachim Langenbach <joachim.langenbach@…>
Branches:
debian/bullseye, master
Children:
37f674d
Parents:
7a831c3
Message:

Logs are now shown with colored water depth as points

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/mapservice/src/server_impl/database/Model.py

    r7a831c3 r1a7f9da  
    300300        def to_geojson(obj):
    301301                result = {
    302                         'type': 'Feature',
    303                         'geometry': {
    304                                 'type': 'LineString',
    305                                 'coordinates': []
    306                         },
    307                         'properties': { }
     302                        'type': 'FeatureCollection',
     303                        'features': []
    308304                }
    309305                if obj.log_entries:
    310                         prop = 0
    311306                        for log in obj.log_entries:
    312307                                location = wkb_to_dict(log.location)
    313                                 result['geometry']['coordinates'].append([location['longitude'], location['latitude']])
    314                                 result['properties']['prop{:09d}'.format(prop)] = {
    315                                         'datetime': log.datetime.isoformat('T'),
    316                                         'waterDepth': log.water_depth
     308                                feature = {
     309                                        'type': 'Feature',
     310                                        'geometry': {
     311                                                'type': 'Point',
     312                                                'coordinates': [location['longitude'], location['latitude']]
     313                                        },
     314                                        'properties': {
     315                                                'datetime': log.datetime.isoformat('T')
     316                                        }
    317317                                }
    318                                 prop += 1
     318                                if log.water_depth is not None:
     319                                        feature['properties']['waterDepth'] = log.water_depth
     320                                result['features'].append(feature)
    319321                return result
    320322
Note: See TracChangeset for help on using the changeset viewer.