tg_geometry 0.2.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +46 -0
  3. data/README.md +107 -14
  4. data/benchmark/_support.rb +450 -5
  5. data/benchmark/batch_packed_vs_loop.rb +38 -6
  6. data/benchmark/ewkb_roundtrip.rb +38 -0
  7. data/benchmark/falcon_concurrency.rb +17 -10
  8. data/benchmark/feature_source.rb +49 -23
  9. data/benchmark/flat_vs_rtree.rb +53 -11
  10. data/benchmark/geom_query.rb +43 -0
  11. data/benchmark/gvl_threshold.rb +10 -11
  12. data/benchmark/nearest_segment.rb +24 -0
  13. data/benchmark/objectspace_memsize.rb +14 -1
  14. data/benchmark/parse_throughput.rb +13 -10
  15. data/benchmark/rss_stability.rb +35 -24
  16. data/docs/GEOMETRY_QUERIES.md +23 -0
  17. data/docs/LIMITATIONS.md +12 -10
  18. data/docs/NEAREST_SEGMENT.md +17 -0
  19. data/docs/SRID_AND_EWKB.md +23 -0
  20. data/ext/tg_geometry/tg_geometry_ext.c +1234 -27
  21. data/lib/tg/geometry/active_record_source.rb +16 -34
  22. data/lib/tg/geometry/active_record_type.rb +61 -0
  23. data/lib/tg/geometry/registry.rb +17 -68
  24. data/lib/tg/geometry/version.rb +1 -1
  25. data/lib/tg/geometry.rb +85 -0
  26. data/spec/active_record_type_spec.rb +45 -0
  27. data/spec/constructors_spec.rb +104 -0
  28. data/spec/fixtures/feature_source/invalid_geometry_middle.geojson +8 -0
  29. data/spec/fixtures/feature_source/malformed_json.geojson +1 -0
  30. data/spec/fixtures/feature_source/mixed_geometry_types.geojson +8 -0
  31. data/spec/fixtures/feature_source/osm_like_feature_collection.geojson +10 -0
  32. data/spec/fixtures/feature_source/properties_null_missing.geojson +7 -0
  33. data/spec/fixtures/feature_source/simple_feature_collection.geojson +15 -0
  34. data/spec/fixtures/postgis/README.md +16 -0
  35. data/spec/fixtures/postgis/boundary_point_cases.geojson +83 -0
  36. data/spec/fixtures/postgis/multipolygon_large.ewkb +0 -0
  37. data/spec/fixtures/postgis/point_4326.ewkb +0 -0
  38. data/spec/fixtures/postgis/polygon_3857.ewkb +0 -0
  39. data/spec/fixtures/postgis/polygon_4326_simple.ewkb +0 -0
  40. data/spec/fixtures/postgis/polygon_4326_with_hole.ewkb +0 -0
  41. data/spec/index_geom_query_spec.rb +68 -0
  42. data/spec/keyword_validation_spec.rb +31 -0
  43. data/spec/nearest_segment_spec.rb +62 -0
  44. data/spec/postgis_fixtures_spec.rb +68 -0
  45. data/spec/srid_spec.rb +43 -0
  46. data/spec/to_ewkb_spec.rb +37 -0
  47. metadata +50 -2
@@ -0,0 +1,23 @@
1
+ # SRID and EWKB
2
+
3
+ EWKB extends WKB with extra metadata bits. PostGIS sets the SRID flag (`0x20000000`) in the geometry type word and inserts a 32-bit SRID after the type header.
4
+
5
+ `tg` already understands EWKB enough to parse the geometry payload correctly, but it does not expose SRID metadata. `tg_geometry` therefore reads the EWKB header at wrapper level before passing the original bytes to `tg_parse_wkb_ix` / `tg_parse_hexn_ix`.
6
+
7
+ The original bytes are not modified. The native `tg_geom` remains a plain planar geometry. The Ruby `TG::Geometry::Geom` wrapper stores SRID metadata in parallel:
8
+
9
+ ```ruby
10
+ geom = TG::Geometry.parse_wkb(ewkb)
11
+ geom.srid # => Integer or nil
12
+ ```
13
+
14
+ `parse_wkb` and `parse_hex` preserve SRID metadata. GeoJSON, WKT, GeoBIN, and `parse(format: :auto)` do not guarantee SRID preservation in v0.3.0.
15
+
16
+ `to_wkb` intentionally stays plain WKB. Use `to_ewkb` for PostGIS-compatible SRID-bearing output:
17
+
18
+ ```ruby
19
+ geom.to_ewkb
20
+ geom.to_ewkb(srid: 4326)
21
+ ```
22
+
23
+ SRID is metadata only. No reprojection, SRID compatibility check, meter conversion, or geodesic calculation is performed.