Changeset 1a7f9da for src/mapservice


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

Location:
src/mapservice
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/mapservice/openapi.yaml

    r7a831c3 r1a7f9da  
    820820        - Feature
    821821        - Point
    822         - LineString
     822        - FeatureCollection
    823823    geoJsonPoint:
    824824      type: object
    … …  
    831831        coordinates:
    832832          $ref: '#/components/schemas/point'
    833     geoJsonLineString:
    834       type: object
    835       description: GeoJson geometry
    836       externalDocs:
    837         url: 'http://geojson.org/geojson-spec.html#id3'
    838       properties:
    839         type:
    840           type: string
    841         coordinates:
    842           type: array
    843           items:
    844             $ref: '#/components/schemas/point'
    845833    sensorDepth:
    846834      type: number
    … …  
    11381126        $ref: '#/components/schemas/LogMetaData'
    11391127    LogGeoJson:
    1140       title: Log in GeoJson format
     1128        title: FeatureCollection representing a Log in GeoJson format
     1129        type: object
     1130        properties:
     1131          type:
     1132            $ref: '#/components/schemas/geoJsonType'
     1133          features:
     1134            type: array
     1135            items:
     1136              $ref: '#/components/schemas/LogEntryGeoJson'
     1137        required:
     1138          - type
     1139          - features
     1140    LogEntryGeoJson:
     1141      title: Feature representing LogEntry in GeoJson format
    11411142      type: object
    11421143      properties:
    … …  
    11441145          $ref: '#/components/schemas/geoJsonType'
    11451146        geometry:
    1146           $ref: '#/components/schemas/geoJsonLineString'
     1147          $ref: '#/components/schemas/geoJsonPoint'
    11471148        properties:
    11481149          type: object
    1149           additionalProperties:
    1150             type: object
    1151             properties:
    1152               name:
    1153                 type: string
    1154               item:
    1155                 title: >-
    1156                   LogEntry as GeoJson property ordered in same order as geometry
    1157                   coordinates
    1158                 type: object
    1159                 properties:
    1160                   datetime:
    1161                     type: string
    1162                     format: date-time
    1163                   waterDepth:
    1164                     $ref: '#/components/schemas/itemName'
    1165                   comment:
    1166                     $ref: '#/components/schemas/comment'
    1167                 required:
    1168                   - datetime
    1169                   - waterDepth
     1150          properties:
     1151            datetime:
     1152              type: string
     1153              format: date-time
     1154            waterDepth:
     1155              type: number
     1156              format: float
     1157          required:
     1158            - datetime
    11701159      required:
    11711160        - type
    … …  
    13841373    LogGeoJson:
    13851374      value:
    1386         type: Feature
    1387         geometry:
    1388           type: LineString
    1389           coordinates:
    1390             - - 90.136111
    1391               - 29.934722
    1392             - - 90.236111
    1393               - 30.034722
    1394           properties:
    1395             prop0:
     1375        type: FeatureCollection
     1376        features:
     1377          - geometry:
     1378              coordinates:
     1379                - 90.136111
     1380                - 29.934722
     1381              type: 'Point'
     1382            properties:
    13961383              datetime: 2017-07-21T10:32:28.000Z
    13971384              waterDepth: 10
    1398             prop1:
     1385          - geometry:
     1386              coordinates:
     1387                - 90.236111
     1388                - 30.034722
     1389              type: Point
     1390            properties:
    13991391              datetime: 2017-07-21T11:32:28.000Z
    14001392              waterDepth: 5
  • 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.