-
-
Notifications
You must be signed in to change notification settings - Fork 824
Flatheadmill geo #2755
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
Open
fulmicoton
wants to merge
22
commits into
main
Choose a base branch
from
flatheadmill-geo
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Flatheadmill geo #2755
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
43b5f34
Implement SPATIAL flag.
flatheadmill 558c99f
Triangle encoding for spatial indexing.
flatheadmill b2a9bb2
Implement polygon tessellation.
flatheadmill 1c66567
Radix selection for block kd-tree partitioning.
flatheadmill 0996bea
Add a surveyor to determine spread and prefix.
flatheadmill f38140f
Add delta compression for block kd-tree leaf nodes.
flatheadmill 2dc46b2
Implement block kd-tree.
flatheadmill ccdf399
XOR delta compression for f64 polygon coordinates.
flatheadmill d3049cb
Triangulation is not just a conversion.
flatheadmill dbbc8c3
Slot block kd-tree into Tantivy.
flatheadmill 459456c
Remove `radix_select.rs`.
flatheadmill 68009bb
Read block kd-tree nodes using `from_le_bytes`.
flatheadmill 9f10279
Complete Spatial/Geometry type integration.
flatheadmill 6da54fa
Revert "Remove `radix_select.rs`."
flatheadmill d26d6c3
Fix `select_nth_unstable_by_key` midpoint duplicates.
flatheadmill 79622f1
bugfix
fulmicoton-dd d8bc0e7
added doc
fulmicoton-dd 32beb06
plastic surgery
fulmicoton-dd 5d03c60
Added bugfix and unit tests
fulmicoton-dd 1619e05
plastic surgery
fulmicoton-dd f85a270
Introduced geopoint.
fulmicoton-dd 643639f
Introduced geopoint.
fulmicoton-dd File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| use geo_types::Point; | ||
| use tantivy::collector::TopDocs; | ||
| use tantivy::query::SpatialQuery; | ||
| use tantivy::schema::{Schema, Value, SPATIAL, STORED, TEXT}; | ||
| use tantivy::spatial::point::GeoPoint; | ||
| use tantivy::{Index, IndexWriter, TantivyDocument}; | ||
| fn main() -> tantivy::Result<()> { | ||
| let mut schema_builder = Schema::builder(); | ||
| schema_builder.add_json_field("properties", STORED | TEXT); | ||
| schema_builder.add_spatial_field("geometry", STORED | SPATIAL); | ||
| let schema = schema_builder.build(); | ||
| let index = Index::create_in_ram(schema.clone()); | ||
| let mut index_writer: IndexWriter = index.writer(50_000_000)?; | ||
| let doc = TantivyDocument::parse_json( | ||
| &schema, | ||
| r#"{ | ||
| "type":"Feature", | ||
| "geometry":{ | ||
| "type":"Polygon", | ||
| "coordinates":[[[-99.483911,45.577697],[-99.483869,45.571457],[-99.481739,45.571461],[-99.474881,45.571584],[-99.473167,45.571615],[-99.463394,45.57168],[-99.463391,45.57883],[-99.463368,45.586076],[-99.48177,45.585926],[-99.48384,45.585953],[-99.483885,45.57873],[-99.483911,45.577697]]] | ||
| }, | ||
| "properties":{ | ||
| "admin_level":"8", | ||
| "border_type":"city", | ||
| "boundary":"administrative", | ||
| "gnis:feature_id":"1267426", | ||
| "name":"Hosmer", | ||
| "place":"city", | ||
| "source":"TIGER/Line® 2008 Place Shapefiles (http://www.census.gov/geo/www/tiger/)", | ||
| "wikidata":"Q2442118", | ||
| "wikipedia":"en:Hosmer, South Dakota" | ||
| } | ||
| }"#, | ||
| )?; | ||
| index_writer.add_document(doc)?; | ||
| index_writer.commit()?; | ||
|
|
||
| let reader = index.reader()?; | ||
| let searcher = reader.searcher(); | ||
| let field = schema.get_field("geometry").unwrap(); | ||
| let query = SpatialQuery::new( | ||
| field, | ||
| [ | ||
| GeoPoint { | ||
| lon: -99.49, | ||
| lat: 45.56, | ||
| }, | ||
| GeoPoint { | ||
| lon: -99.45, | ||
| lat: 45.59, | ||
| }, | ||
| ], | ||
| tantivy::query::SpatialQueryType::Intersects, | ||
| ); | ||
| let hits = searcher.search(&query, &TopDocs::with_limit(10).order_by_score())?; | ||
| for (_score, doc_address) in &hits { | ||
| let retrieved_doc: TantivyDocument = searcher.doc(*doc_address)?; | ||
| if let Some(field_value) = retrieved_doc.get_first(field) { | ||
| if let Some(geometry_box) = field_value.as_value().into_geometry() { | ||
| println!("Retrieved geometry: {:?}", geometry_box); | ||
| } | ||
| } | ||
| } | ||
| assert_eq!(hits.len(), 1); | ||
| Ok(()) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.