digidem / osm-p2p-db

Peer-to-peer database for OpenStreetMap data
BSD 2-Clause "Simplified" License
236 stars 25 forks source link

new types #10

Closed ghost closed 8 years ago

ghost commented 8 years ago

This feature would support adding custom new types on top of the existing entities. For example, an observation type might describe a fact at a particular time and place by linking to a node, but observations would be immutable whereas nodes and other entities can mutate.

e.g. when mapping a coffee shop that does not currently exist in the db, the first step would be to make an observation with a GPS/mobile app: "I was here and there is a coffee shop here", and on the basis of that we can create a coffee shop either automatically or manually (this is actually the current OSM workflow using GPX files from a GPS). On a subsequent visit to the coffee shop you might observe that the name has change, or it has closed down, and you would make an additional observation linked to the coffee shop node or way indicating its current status.

Aside from reading refs and members from ways and relations, the database doesn't care what type a document is, so observation types could be added right now. Observations would likely need their own index over the hyperlog, which is also possible to do externally before the log is passed to osm-p2p-db.

I think this use case warrants an example. If the example is messy or difficult, I'll make a separate module or plugin mechanism to make custom types easier to deal with.

ghost commented 8 years ago

Another custom type worth supporting is localized legend presets.

ghost commented 8 years ago

The observation example should also have an index for sorting observations by creation date.

ghost commented 8 years ago

I have this working in osm-p2p/example/obs.js

$ rm -rf /tmp/osmdb/
$ node obs.js create '{"type":"node","lat":64.5,"lon":-120.9}'
78ac08875010bc25
$ node obs.js create '{"type":"observation","ref":"78ac08875010bc25","tags":{"comment":"whatever"}}'
5a0ac8da1d5d7b94
$ node obs.js query 64,65 -121,-120
{ type: 'node',
  lat: 64.5,
  lon: -120.9,
  id: '78ac08875010bc25',
  version: '79ef998702011be7fdf263c2e924cfa64fdccb4b2ef996164763b89650d12597',
  observations: [ { type: 'observation', ref: '78ac08875010bc25', tags: [Object] } ] }
gmaclennan commented 8 years ago

Moving this discussion to digidem/osm-p2p-observations and https://github.com/digidem/osm-p2p-db/issues/23