-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use hexWKB in JSON diff/show output #71
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
8addc82
to
7807bcf
Compare
g = gpkg.geom_to_ogr(v) | ||
f["geometry"] = json.loads(g.ExportToJson()) | ||
g = gpkg.gpkg_geom_to_ogr(v) | ||
f['geometry'] = json.loads(g.ExportToJson()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OT: I feel like I've written this code 1000 times. Maybe it's time to fix this in OGR?
(not right this second)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ie some kind of ogr.ExportToDeserializedJson()
method?
One problem is that different bindings would have to implement it differently. I'm completely ignorant of how Java handles deserialized JSON but I'm not sure I want to know either...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In principle, yes (ExportToJsonStruct()
?). It's possible to add language-specific methods in SWIG, so could ignore Java in the meantime.
This replaces GeoJSON geometries with (little-endian) hex-encoded WKB in `show --json` and `diff --json` commands. `--geojson` output is unaffected. This: * reduces patch/diff size by quite a lot, especially for large geometries * makes patch generation/consumption more efficient; no pass via OGR is required in most circumstances. * improves support for exotic geometries (GeoJSON doesn't support curved geometry types) fixes #62
Including endianness and envelopes
They're not GeoJSON anymore anyway, because we're using hexWKB geometries, so best not to pretend they are.
c09db8f
to
af1fc02
Compare
Supports curves and POINT EMPTY
af1fc02
to
304c827
Compare
Can you summarize/include/link examples of whatever formats we have finalised on? |
sno/diff-view.html
Outdated
@@ -125,7 +125,7 @@ | |||
}).addTo(map) | |||
|
|||
var layerGroup = L.featureGroup() | |||
for (let [dataset, diff] of Object.entries(DATA['sno.diff/v1'])) { | |||
for (let [dataset, diff] of Object.entries(DATA['sno.diff/v1+hexwkb'])) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how's it going to view wkb in the browser? Surely needs the GeoJSON output?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did this by accident, so good catch. I'm surprised this is using the json diff and not the geojson diff. That throws a spanner in the works a bit, because I can't just switch tot he geojson one, it's quite different. Will attempt to though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's using the JSON because the geojson ends up in multiple files
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alternatively, it could serialise all the geojson into an array in the HTML or something. No problem doing that, but it needs to work :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The --geojson
diff doesn't actually differentiate multiple datasets, so it's not enough for this.
So I guess to make this work, I need to add a format variant for --json
diffs with GeoJSON geometries?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don’t understand... the geojson gets written to multiple files in a directory.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
aha, so it does (if you have >1 dataset). I just saw it with one dataset and got lost on how the different ones were going to be differentiated, but didn't realise it used multiple files
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
otherwise there's no meaningful way to view them in QGIS/etc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed in cb28c3b - it now writes geojson files to a temp dir and then reads them back in again. Could have done it some other way, e.g. by passing an empty dict to resolve_object_path
and making it create a StringIO for each dataset, but it felt like a Weird Hack so I didn't
Possibly commented out by accident in b5f7c7c
Generate it from the `geojson` diff rather than the `json` one, because the `json` one now uses hexWKB geometries. Because the layout's a bit different, this means the JS in the HTML template needs to do a bit more work, but it's quite achievable. Yay for ES7
Since #71 we haven't used GeoJSON for diffs or patches, however we still have some GeoJSON artifacts that are now unnecessary and unused. This moves all feature attributes into the feature object, and removes the `properties`, `geometry` and `id` keys.
Since #71 we haven't used GeoJSON for diffs or patches, however we still have some GeoJSON artifacts that are now unnecessary and unused. This moves all feature attributes into the feature object, and removes the `properties`, `geometry` and `id` keys.
This replaces GeoJSON geometries with (little-endian) hex-encoded WKB
in
show --json
anddiff --json
commands.--geojson
output isunaffected.
This:
geometries
required in most circumstances.
curved geometry types)
fixes #62
Size of output
If you combine this with
--json-style=extracompact
from #70: