Last active
April 6, 2020 19:47
-
-
Save javipalanca/58beae4fc91bbc21e8c47ccf534e6dbe to your computer and use it in GitHub Desktop.
Spatial and time queries
This file contains 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
def time_interval(t1start, t1end, t2start, t2end): | |
return (t1start <= t2start <= t1end) or (t2start <= t1start <= t2end) | |
// Initialize database | |
GraphDatabaseService graph = new EmbeddedGraphDatabase("db"); | |
SpatialDatabaseService db = new SpatialDatabaseService(graph); | |
SimplePointLayer layer = db.createSimplePointLayer("neo-text"); | |
// Add locations | |
for (Coordinate coordinate : | |
makeCoordinateDataFromTextFile("NEO4J-SPATIAL.txt")) { | |
layer.add(coordinate); | |
} | |
// Search for nearby locations | |
Coordinate myPosition = new Coordinate(13.76, 55.56); | |
List<SpatialDatabaseRecord> results = | |
layer.findClosestPointsTo(myPosition, 10.0); | |
graph.shutdown(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment