Skip to content

[DATASTORE] Add optional polygon to geo_point #276

@jo-asplin-met-no

Description

@jo-asplin-met-no

For some use cases, like observations that represent radar images, it would be useful to associate not only a point, but also an optional, arbitrarily sized polygon with the observation. For example, a polygon of size 4 could represent the corners of (a bounding box of) a radar image. It would also be useful to have the polygon come in addition to the existing point (instead of just replacing it) so that the latter could be considered a base/reference point. One use case for this is to have the base point represent the location of the radar itself, while the polygon represents the radar image.

One approach for supporting this feature is to implement (essentially) the following tasks:

Task 1: Extend the geo_point table with a polygon:

CREATE TABLE geo_point (
    id BIGINT PRIMARY KEY GENERATED ALWAYS AS IDENTITY,
    point GEOGRAPHY(Point, 4326) NOT NULL,
    polygon GEOGRAPHY(Polygon, 4326),
    CONSTRAINT unique_main UNIQUE NULLS NOT DISTINCT (point, polygon)
);

Task 2: In ObsMetadata in datastore.proto, ensure that geo_point and geo_polygon are no longer mutually exclusive by removing the oneof geometry { ... } block around their declarations.

Task 3: Extend the following functions to accommodate an optional polygon in each observation:

  • getGeoPointIDs() (in putobservations.go)
  • getSpatialExtent() (in getextents.go)
  • getPolygonFilter() (in getobservations.go)
  • getCircleFilter() (in getobservations.go)

NOTE: The latter two functions must generate essentially the following WHERE clause, where gp is the geo point/polygon associated with the observation, and rg is the requested geometry (polygon or circle):

rg.contains(gp.point) OR (gp.polygonExists() AND rg.intersects(gp.polygon))

Metadata

Metadata

Labels

datastoreFor issues and PR related to the datastore

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions