SlideShare une entreprise Scribd logo
1  sur  32
Télécharger pour lire hors ligne
GeoSpatial Graphs
made easy with
Luigi Dell’Aquila
Prague, 20-21 October 2016
Luigi Dell’Aquila
Core Developer and Director of Consulting
OrientDB LTD
Twitter: @ldellaquila
http://www.orientdb.com
Luigi Dell’Aquila @ldellaquila Prague, 20-21 October 2016
Our goal
Luigi Dell’Aquila @ldellaquila Prague, 20-21 October 2016
Summary
•What is OrientDB
•OrientDB GeoSpatial API
•Importing Geo data (Node.js)
•Querying Geo data (OrientDB Studio)
•Displaying Geo data (Angular2, Google Maps)
•Adding Relationships - graph data
•Graph + Spatial queries
Luigi Dell’Aquila @ldellaquila Prague, 20-21 October 2016
What is OrientDB
•Multi-Model Database (Document, Graph and more)
•Tables Classes
•Extended SQL
•JOIN Physical Pointers
•Schema, No-Schema, Hybrid
•HTTP + Binary protocols
•Stand-alone or Embedded
•Distributed Multi-Master
•Apache 2 license
Luigi Dell’Aquila @ldellaquila Prague, 20-21 October 2016
Install
•http://www.orientdb.com/download/
•http://central.maven.org/maven2/com/
orientechnologies/orientdb-spatial/VERSION/
orientdb-spatial-VERSION-dist.jar
> cd orientdb-community/bin/
> ./server.sh
Luigi Dell’Aquila @ldellaquila Prague, 20-21 October 2016
OrientDB GeoSpatial Classes
•OPoint
•OLine
•OPolygon
•OMultiPoint
•OMultiline
•OMultiPlygon
Luigi Dell’Aquila @ldellaquila Prague, 20-21 October 2016
OrientDB GeoSpatial Functions
•ST_GeomFromText(text)
•ST_Equals(geom, geom)
•ST_Contains(geom, geom)
•ST_Disjoint(geom, geom)
•ST_Intersects(geom, geom)
•ST_Distance_Sphere(geom, geom)
•and more…
Luigi Dell’Aquila @ldellaquila Prague, 20-21 October 2016
Our Data Model
CREATE CLASS POI EXTENDS V
CREATE PROPERTY POI.location EMBEDDED OPoint
CREATE INDEX POI.location on POI(location) SPATIAL ENGINE LUCENE
CREATE CLASS Natural EXTENDS V
CREATE PROPERTY Natural.location EMBEDDED OPolygon
CREATE INDEX Natural.location on Natural(location) SPATIAL ENGINE LUCENE
CREATE CLASS Person EXTENDS V
CREATE PROPERTY Person.location EMBEDDED OPoint
CREATE CLASS FriendOf EXTENDS E
Luigi Dell’Aquila @ldellaquila Prague, 20-21 October 2016
Our Data Source (WKT)
WKT,osm_id,name,type
"POINT (14.4641804 50.0972109)",24569342,"Invalidovna, Metro B",station
"POINT (14.4739792 50.1036789)",24569358,"Palmovka, Metro B",station
"POINT (14.4921863 50.1062907)",24569412,"Českomoravská, Metro B",station
Luigi Dell’Aquila @ldellaquila Prague, 20-21 October 2016
Now let’s import data!
> npm init
> npm install orientjs
> npm install fast-csv
> touch index.js
import files
http://www.mapcruzin.com/free-czech-republic-maps.htm
(convert to WKT using QGis)
Luigi Dell’Aquila @ldellaquila Prague, 20-21 October 2016
Dependencies
var fs = require("fs")

var ODatabase = require("orientjs").ODatabase

var csv = require("fast-csv")
Luigi Dell’Aquila @ldellaquila Prague, 20-21 October 2016
Read from CSV
var stream = fs.createReadStream("data/poland-poi.csv");



var csvStream = csv.parse({headers: true})

.on("data", function(data){

console.log(data)

})

.on("end", function(){

console.log("Done!")

});



stream.pipe(csvStream);


Luigi Dell’Aquila @ldellaquila Prague, 20-21 October 2016
DB connection
var db = new ODatabase({

host: "localhost",

port: 2424,

username: "admin",

password: "admin",

name: "geo"

})
db.open().then(function(){

}


Luigi Dell’Aquila @ldellaquila Prague, 20-21 October 2016
Insert
var insertElement = function(data){

db.insert().into(className).set(

{

name: data.name,

type: data.type,

location: db.rawExpression("ST_GeomFromText('"+data.WKT+"')")

}

).one().then(function(){})

}


Luigi Dell’Aquila @ldellaquila Prague, 20-21 October 2016
Is it done?
Not yet :-(
Node.js… asynchronous… promises…
Final version:
https://github.com/luigidellaquila/wkt-to-orient
Luigi Dell’Aquila @ldellaquila Prague, 20-21 October 2016
Querying geo data
We are here:
(50.10902, 14.5831653)
(lat, lon)
Front-End!
Luigi Dell’Aquila @ldellaquila Prague, 20-21 October 2016
Clone the scaffolding
> git clone https://github.com/luigidellaquila/geospatial-demo
> git checkout warsaw_demo_step0
> cd geospatial-demo
> npm install
(it’s a clone of https://github.com/angular/quickstart)
> npm start
Luigi Dell’Aquila @ldellaquila Prague, 20-21 October 2016
Clone the scaffolding
> git clone https://github.com/luigidellaquila/geospatial-demo
> git checkout warsaw_demo_step0
> cd geospatial-demo
> npm install
(it’s a clone of https://github.com/angular/quickstart)
> npm start
> cd <orientdb-home>/www
> ln -s <quickstart-path>
> tsc -w
Luigi Dell’Aquila @ldellaquila Prague, 20-21 October 2016
We need Google Maps
<script src=“https://maps.googleapis.com/maps/api/js?key=API_KEY"

async defer></script>
Luigi Dell’Aquila @ldellaquila Prague, 20-21 October 2016
Let’s display a map (app.html)
<div class=“container">

<div class="row">

<div class="col-md-12" id="map" style=“height:600px"></div>

</div>

</div>
Luigi Dell’Aquila @ldellaquila Prague, 20-21 October 2016
Draw the map
drawMap(){

var controller = this;

let mapProp = {

center: new google.maps.LatLng(52.231807953759706, 21.013154983520508),

zoom: 16,

mapTypeId: google.maps.MapTypeId.ROADMAP

};



controller.map = new google.maps.Map(document.getElementById("map"), mapProp);

controller.map.addListener("click", function(point: any){

controller.zone.run(()=> {

controller.lat = point.latLng.lat();

controller.lon = point.latLng.lng();

});

});

}
Luigi Dell’Aquila @ldellaquila Prague, 20-21 October 2016
Create a Person
createPerson(): void{

var location = {

// the location object

}



var queryString = ””; // OrientDB statement



this.orient.command(
queryString,
(result) => { /* Success callback */ },
(error) => { /* Error callback */ }
);

}

Luigi Dell’Aquila @ldellaquila Prague, 20-21 October 2016
Create a Person
createPerson(): void{

var location = {

"@class": "OPoint",

coordinates: [this.lon, this.lat]

}



var queryString = ””; // OrientDB statement



this.orient.command(
queryString,
(result) => { /* Success callback */ },
(error) => { /* Error callback */ }
);}

Luigi Dell’Aquila @ldellaquila Prague, 20-21 October 2016
Create a Person
createPerson(): void{

var location = {

"@class": "OPoint",

coordinates: [this.lon, this.lat]

}



var queryString = `insert into Person 

set name = '${this.personName}', 

location = ${JSON.stringify(location)}`;



this.orient.command(
queryString,
(result) => { /* Success callback */ },
(error) => { /* Error callback */ }
);

}

Luigi Dell’Aquila @ldellaquila Prague, 20-21 October 2016
Create a Person
createPerson(): void{

var location = {

"@class": "OPoint",

coordinates: [this.lon, this.lat]

}



var queryString = `insert into Person 

set name = '${this.personName}', 

location = ${JSON.stringify(location)}`;



this.orient.command(
queryString,
(res) => {

let body = res.json();

let person = body.result[0];

this.addPersonToMap(person)

},
(e) => { console.log(e) });

}

Luigi Dell’Aquila @ldellaquila Prague, 20-21 October 2016
Add Person Vertex to Orient via REST API
command(statement: string, success: (data: any) => void, error: (err: any) => void): void{

var url = this.url + "sql/-/-1"


var headers = new Headers();

headers.append("Authorization", "Basic " + btoa(this.username+":"+this.password));



this.http.post( // HTTP POST

url, // the URL

JSON.stringify({

"command": statement // the SQL command

}),

{headers: headers} // the authentication data

).toPromise()

.then(success)

.catch(error);

}
Luigi Dell’Aquila @ldellaquila Prague, 20-21 October 2016
Add Person to the Map
addPersonToMap(personData:any){

let location = personData.location;

let coordinates = location.coordinates;

let controller = this;

let marker = new google.maps.Marker({

position: {lat:coordinates[1], lng:coordinates[0]},

map: this.map,

title: personData.name,

rid: personData["@rid"]

});

google.maps.event.addListener(marker, 'click', function() {

controller.onMarkerClick(marker);

});

}
Luigi Dell’Aquila @ldellaquila Prague, 20-21 October 2016
Add an edge between people
(FriendOf)
createEdge(from:any, to:any): void{

this.orient.command(

`create edge FriendOf from ${from.rid} to ${to.rid}`,

(x)=>{console.log(x)},

(x)=>{console.log(x)}

)

this.addEdgeBetweenMarkersToMap(from, to);

}
Query the
Geospatial Graph
(DEMO)
Thank you!

Contenu connexe

Tendances

Akka stream and Akka CQRS
Akka stream and  Akka CQRSAkka stream and  Akka CQRS
Akka stream and Akka CQRSMilan Das
 
Jena University Talk 2016.03.09 -- SQL at Zalando Technology
Jena University Talk 2016.03.09 -- SQL at Zalando TechnologyJena University Talk 2016.03.09 -- SQL at Zalando Technology
Jena University Talk 2016.03.09 -- SQL at Zalando TechnologyValentine Gogichashvili
 
OrientDB - the 2nd generation of (Multi-Model) NoSQL - Devoxx Belgium 2015
OrientDB - the 2nd generation  of  (Multi-Model) NoSQL - Devoxx Belgium 2015OrientDB - the 2nd generation  of  (Multi-Model) NoSQL - Devoxx Belgium 2015
OrientDB - the 2nd generation of (Multi-Model) NoSQL - Devoxx Belgium 2015Luigi Dell'Aquila
 
Utilising the data attribute
Utilising the data attributeUtilising the data attribute
Utilising the data attributeRichard Martens
 
Codemotion akka persistence, cqrs%2 fes y otras siglas del montón
Codemotion   akka persistence, cqrs%2 fes y otras siglas del montónCodemotion   akka persistence, cqrs%2 fes y otras siglas del montón
Codemotion akka persistence, cqrs%2 fes y otras siglas del montónJavier Santos Paniego
 
Spark SQL - 10 Things You Need to Know
Spark SQL - 10 Things You Need to KnowSpark SQL - 10 Things You Need to Know
Spark SQL - 10 Things You Need to KnowKristian Alexander
 
OrientDB - the 2nd generation of (Multi-Model) NoSQL - J On The Beach 2016
OrientDB - the 2nd generation of (Multi-Model) NoSQL  - J On The Beach 2016OrientDB - the 2nd generation of (Multi-Model) NoSQL  - J On The Beach 2016
OrientDB - the 2nd generation of (Multi-Model) NoSQL - J On The Beach 2016Luigi Dell'Aquila
 
Spark Your Legacy (Spark Summit 2016)
Spark Your Legacy (Spark Summit 2016)Spark Your Legacy (Spark Summit 2016)
Spark Your Legacy (Spark Summit 2016)Tzach Zohar
 
Big Data processing with Spark, Scala or Java?
Big Data processing with Spark, Scala or Java?Big Data processing with Spark, Scala or Java?
Big Data processing with Spark, Scala or Java?Erik-Berndt Scheper
 
Introduction to interactive data visualisation using R Shiny
Introduction to interactive data visualisation using R ShinyIntroduction to interactive data visualisation using R Shiny
Introduction to interactive data visualisation using R Shinyanamarisaguedes
 

Tendances (11)

SFScon 2020 - Peter Hopfgartner - Open Data de luxe
SFScon 2020 - Peter Hopfgartner - Open Data de luxeSFScon 2020 - Peter Hopfgartner - Open Data de luxe
SFScon 2020 - Peter Hopfgartner - Open Data de luxe
 
Akka stream and Akka CQRS
Akka stream and  Akka CQRSAkka stream and  Akka CQRS
Akka stream and Akka CQRS
 
Jena University Talk 2016.03.09 -- SQL at Zalando Technology
Jena University Talk 2016.03.09 -- SQL at Zalando TechnologyJena University Talk 2016.03.09 -- SQL at Zalando Technology
Jena University Talk 2016.03.09 -- SQL at Zalando Technology
 
OrientDB - the 2nd generation of (Multi-Model) NoSQL - Devoxx Belgium 2015
OrientDB - the 2nd generation  of  (Multi-Model) NoSQL - Devoxx Belgium 2015OrientDB - the 2nd generation  of  (Multi-Model) NoSQL - Devoxx Belgium 2015
OrientDB - the 2nd generation of (Multi-Model) NoSQL - Devoxx Belgium 2015
 
Utilising the data attribute
Utilising the data attributeUtilising the data attribute
Utilising the data attribute
 
Codemotion akka persistence, cqrs%2 fes y otras siglas del montón
Codemotion   akka persistence, cqrs%2 fes y otras siglas del montónCodemotion   akka persistence, cqrs%2 fes y otras siglas del montón
Codemotion akka persistence, cqrs%2 fes y otras siglas del montón
 
Spark SQL - 10 Things You Need to Know
Spark SQL - 10 Things You Need to KnowSpark SQL - 10 Things You Need to Know
Spark SQL - 10 Things You Need to Know
 
OrientDB - the 2nd generation of (Multi-Model) NoSQL - J On The Beach 2016
OrientDB - the 2nd generation of (Multi-Model) NoSQL  - J On The Beach 2016OrientDB - the 2nd generation of (Multi-Model) NoSQL  - J On The Beach 2016
OrientDB - the 2nd generation of (Multi-Model) NoSQL - J On The Beach 2016
 
Spark Your Legacy (Spark Summit 2016)
Spark Your Legacy (Spark Summit 2016)Spark Your Legacy (Spark Summit 2016)
Spark Your Legacy (Spark Summit 2016)
 
Big Data processing with Spark, Scala or Java?
Big Data processing with Spark, Scala or Java?Big Data processing with Spark, Scala or Java?
Big Data processing with Spark, Scala or Java?
 
Introduction to interactive data visualisation using R Shiny
Introduction to interactive data visualisation using R ShinyIntroduction to interactive data visualisation using R Shiny
Introduction to interactive data visualisation using R Shiny
 

Similaire à GeeCON Prague 2016 - Geospatial Graphs made easy with OrientDB

Geospatial Graphs made easy with OrientDB - Codemotion Warsaw 2016
Geospatial Graphs made easy with OrientDB - Codemotion Warsaw 2016Geospatial Graphs made easy with OrientDB - Codemotion Warsaw 2016
Geospatial Graphs made easy with OrientDB - Codemotion Warsaw 2016Luigi Dell'Aquila
 
OSCON 2011 CouchApps
OSCON 2011 CouchAppsOSCON 2011 CouchApps
OSCON 2011 CouchAppsBradley Holt
 
CouchDB Mobile - From Couch to 5K in 1 Hour
CouchDB Mobile - From Couch to 5K in 1 HourCouchDB Mobile - From Couch to 5K in 1 Hour
CouchDB Mobile - From Couch to 5K in 1 HourPeter Friese
 
Conceptos básicos. Seminario web 4: Indexación avanzada, índices de texto y g...
Conceptos básicos. Seminario web 4: Indexación avanzada, índices de texto y g...Conceptos básicos. Seminario web 4: Indexación avanzada, índices de texto y g...
Conceptos básicos. Seminario web 4: Indexación avanzada, índices de texto y g...MongoDB
 
Geospatial Enhancements in MongoDB 2.4
Geospatial Enhancements in MongoDB 2.4Geospatial Enhancements in MongoDB 2.4
Geospatial Enhancements in MongoDB 2.4MongoDB
 
JavaCro 2014 Scala and Java EE 7 Development Experiences
JavaCro 2014 Scala and Java EE 7 Development ExperiencesJavaCro 2014 Scala and Java EE 7 Development Experiences
JavaCro 2014 Scala and Java EE 7 Development ExperiencesPeter Pilgrim
 
GraphQL - when REST API is to less - lessons learned
GraphQL - when REST API is to less - lessons learnedGraphQL - when REST API is to less - lessons learned
GraphQL - when REST API is to less - lessons learnedMarcinStachniuk
 
Visualizing Web Data Query Results
Visualizing Web Data Query ResultsVisualizing Web Data Query Results
Visualizing Web Data Query ResultsAnja Jentzsch
 
WWW2012 Tutorial Visualizing SPARQL Queries
WWW2012 Tutorial Visualizing SPARQL QueriesWWW2012 Tutorial Visualizing SPARQL Queries
WWW2012 Tutorial Visualizing SPARQL QueriesPablo Mendes
 
SDKs, the good the bad the ugly - Japan
SDKs, the good the bad the ugly - JapanSDKs, the good the bad the ugly - Japan
SDKs, the good the bad the ugly - Japantristansokol
 
WebSocket JSON Hackday
WebSocket JSON HackdayWebSocket JSON Hackday
WebSocket JSON HackdaySomay Nakhal
 
D3 Mapping Visualization
D3 Mapping VisualizationD3 Mapping Visualization
D3 Mapping VisualizationSudhir Chowbina
 
Hd insight programming
Hd insight programmingHd insight programming
Hd insight programmingCasear Chu
 
2014 bigdatacamp asya_kamsky
2014 bigdatacamp asya_kamsky2014 bigdatacamp asya_kamsky
2014 bigdatacamp asya_kamskyData Con LA
 
Crafting Evolvable Api Responses
Crafting Evolvable Api ResponsesCrafting Evolvable Api Responses
Crafting Evolvable Api Responsesdarrelmiller71
 
Lasso and Couchdb : the happy couple
Lasso and Couchdb : the happy coupleLasso and Couchdb : the happy couple
Lasso and Couchdb : the happy coupleAri Najarian
 
My way to clean android (EN) - Android day salamanca edition
My way to clean android (EN) - Android day salamanca editionMy way to clean android (EN) - Android day salamanca edition
My way to clean android (EN) - Android day salamanca editionChristian Panadero
 

Similaire à GeeCON Prague 2016 - Geospatial Graphs made easy with OrientDB (20)

Geospatial Graphs made easy with OrientDB - Codemotion Warsaw 2016
Geospatial Graphs made easy with OrientDB - Codemotion Warsaw 2016Geospatial Graphs made easy with OrientDB - Codemotion Warsaw 2016
Geospatial Graphs made easy with OrientDB - Codemotion Warsaw 2016
 
OSCON 2011 CouchApps
OSCON 2011 CouchAppsOSCON 2011 CouchApps
OSCON 2011 CouchApps
 
CouchDB Mobile - From Couch to 5K in 1 Hour
CouchDB Mobile - From Couch to 5K in 1 HourCouchDB Mobile - From Couch to 5K in 1 Hour
CouchDB Mobile - From Couch to 5K in 1 Hour
 
Conceptos básicos. Seminario web 4: Indexación avanzada, índices de texto y g...
Conceptos básicos. Seminario web 4: Indexación avanzada, índices de texto y g...Conceptos básicos. Seminario web 4: Indexación avanzada, índices de texto y g...
Conceptos básicos. Seminario web 4: Indexación avanzada, índices de texto y g...
 
Geospatial Enhancements in MongoDB 2.4
Geospatial Enhancements in MongoDB 2.4Geospatial Enhancements in MongoDB 2.4
Geospatial Enhancements in MongoDB 2.4
 
CARTO ENGINE
CARTO ENGINECARTO ENGINE
CARTO ENGINE
 
JavaCro'14 - Scala and Java EE 7 Development Experiences – Peter Pilgrim
JavaCro'14 - Scala and Java EE 7 Development Experiences – Peter PilgrimJavaCro'14 - Scala and Java EE 7 Development Experiences – Peter Pilgrim
JavaCro'14 - Scala and Java EE 7 Development Experiences – Peter Pilgrim
 
JavaCro 2014 Scala and Java EE 7 Development Experiences
JavaCro 2014 Scala and Java EE 7 Development ExperiencesJavaCro 2014 Scala and Java EE 7 Development Experiences
JavaCro 2014 Scala and Java EE 7 Development Experiences
 
GraphQL - when REST API is to less - lessons learned
GraphQL - when REST API is to less - lessons learnedGraphQL - when REST API is to less - lessons learned
GraphQL - when REST API is to less - lessons learned
 
Visualizing Web Data Query Results
Visualizing Web Data Query ResultsVisualizing Web Data Query Results
Visualizing Web Data Query Results
 
WWW2012 Tutorial Visualizing SPARQL Queries
WWW2012 Tutorial Visualizing SPARQL QueriesWWW2012 Tutorial Visualizing SPARQL Queries
WWW2012 Tutorial Visualizing SPARQL Queries
 
SDKs, the good the bad the ugly - Japan
SDKs, the good the bad the ugly - JapanSDKs, the good the bad the ugly - Japan
SDKs, the good the bad the ugly - Japan
 
WebSocket JSON Hackday
WebSocket JSON HackdayWebSocket JSON Hackday
WebSocket JSON Hackday
 
D3 Mapping Visualization
D3 Mapping VisualizationD3 Mapping Visualization
D3 Mapping Visualization
 
Hd insight programming
Hd insight programmingHd insight programming
Hd insight programming
 
Kill the DBA
Kill the DBAKill the DBA
Kill the DBA
 
2014 bigdatacamp asya_kamsky
2014 bigdatacamp asya_kamsky2014 bigdatacamp asya_kamsky
2014 bigdatacamp asya_kamsky
 
Crafting Evolvable Api Responses
Crafting Evolvable Api ResponsesCrafting Evolvable Api Responses
Crafting Evolvable Api Responses
 
Lasso and Couchdb : the happy couple
Lasso and Couchdb : the happy coupleLasso and Couchdb : the happy couple
Lasso and Couchdb : the happy couple
 
My way to clean android (EN) - Android day salamanca edition
My way to clean android (EN) - Android day salamanca editionMy way to clean android (EN) - Android day salamanca edition
My way to clean android (EN) - Android day salamanca edition
 

Plus de Luigi Dell'Aquila

OrientDB - Voxxed Days Berlin 2016
OrientDB - Voxxed Days Berlin 2016OrientDB - Voxxed Days Berlin 2016
OrientDB - Voxxed Days Berlin 2016Luigi Dell'Aquila
 
OrientDB - Voxxed Days Berlin 2016
OrientDB - Voxxed Days Berlin 2016OrientDB - Voxxed Days Berlin 2016
OrientDB - Voxxed Days Berlin 2016Luigi Dell'Aquila
 
OrientDB - the 2nd generation of (Multi-Model) NoSQL
OrientDB - the 2nd generation  of  (Multi-Model) NoSQLOrientDB - the 2nd generation  of  (Multi-Model) NoSQL
OrientDB - the 2nd generation of (Multi-Model) NoSQLLuigi Dell'Aquila
 
​Fully Reactive - from Data to UI with OrientDB + Node.js + Socket.io
​Fully Reactive - from Data to UI with OrientDB + Node.js + Socket.io​Fully Reactive - from Data to UI with OrientDB + Node.js + Socket.io
​Fully Reactive - from Data to UI with OrientDB + Node.js + Socket.ioLuigi Dell'Aquila
 
OrientDB - cloud barcamp Libero Cloud
OrientDB - cloud barcamp Libero CloudOrientDB - cloud barcamp Libero Cloud
OrientDB - cloud barcamp Libero CloudLuigi Dell'Aquila
 
Orient DB on the cloud - Cloud Party 2013
Orient DB on the cloud - Cloud Party 2013Orient DB on the cloud - Cloud Party 2013
Orient DB on the cloud - Cloud Party 2013Luigi Dell'Aquila
 

Plus de Luigi Dell'Aquila (8)

OrientDB - Voxxed Days Berlin 2016
OrientDB - Voxxed Days Berlin 2016OrientDB - Voxxed Days Berlin 2016
OrientDB - Voxxed Days Berlin 2016
 
OrientDB - Voxxed Days Berlin 2016
OrientDB - Voxxed Days Berlin 2016OrientDB - Voxxed Days Berlin 2016
OrientDB - Voxxed Days Berlin 2016
 
OrientDB - the 2nd generation of (Multi-Model) NoSQL
OrientDB - the 2nd generation  of  (Multi-Model) NoSQLOrientDB - the 2nd generation  of  (Multi-Model) NoSQL
OrientDB - the 2nd generation of (Multi-Model) NoSQL
 
​Fully Reactive - from Data to UI with OrientDB + Node.js + Socket.io
​Fully Reactive - from Data to UI with OrientDB + Node.js + Socket.io​Fully Reactive - from Data to UI with OrientDB + Node.js + Socket.io
​Fully Reactive - from Data to UI with OrientDB + Node.js + Socket.io
 
OrientDB meetup roma 2014
OrientDB meetup roma 2014OrientDB meetup roma 2014
OrientDB meetup roma 2014
 
OrientDB Codemotion 2014
OrientDB Codemotion 2014OrientDB Codemotion 2014
OrientDB Codemotion 2014
 
OrientDB - cloud barcamp Libero Cloud
OrientDB - cloud barcamp Libero CloudOrientDB - cloud barcamp Libero Cloud
OrientDB - cloud barcamp Libero Cloud
 
Orient DB on the cloud - Cloud Party 2013
Orient DB on the cloud - Cloud Party 2013Orient DB on the cloud - Cloud Party 2013
Orient DB on the cloud - Cloud Party 2013
 

Dernier

Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 

Dernier (20)

Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 

GeeCON Prague 2016 - Geospatial Graphs made easy with OrientDB

  • 1. GeoSpatial Graphs made easy with Luigi Dell’Aquila Prague, 20-21 October 2016
  • 2. Luigi Dell’Aquila Core Developer and Director of Consulting OrientDB LTD Twitter: @ldellaquila http://www.orientdb.com
  • 3. Luigi Dell’Aquila @ldellaquila Prague, 20-21 October 2016 Our goal
  • 4. Luigi Dell’Aquila @ldellaquila Prague, 20-21 October 2016 Summary •What is OrientDB •OrientDB GeoSpatial API •Importing Geo data (Node.js) •Querying Geo data (OrientDB Studio) •Displaying Geo data (Angular2, Google Maps) •Adding Relationships - graph data •Graph + Spatial queries
  • 5. Luigi Dell’Aquila @ldellaquila Prague, 20-21 October 2016 What is OrientDB •Multi-Model Database (Document, Graph and more) •Tables Classes •Extended SQL •JOIN Physical Pointers •Schema, No-Schema, Hybrid •HTTP + Binary protocols •Stand-alone or Embedded •Distributed Multi-Master •Apache 2 license
  • 6. Luigi Dell’Aquila @ldellaquila Prague, 20-21 October 2016 Install •http://www.orientdb.com/download/ •http://central.maven.org/maven2/com/ orientechnologies/orientdb-spatial/VERSION/ orientdb-spatial-VERSION-dist.jar > cd orientdb-community/bin/ > ./server.sh
  • 7. Luigi Dell’Aquila @ldellaquila Prague, 20-21 October 2016 OrientDB GeoSpatial Classes •OPoint •OLine •OPolygon •OMultiPoint •OMultiline •OMultiPlygon
  • 8. Luigi Dell’Aquila @ldellaquila Prague, 20-21 October 2016 OrientDB GeoSpatial Functions •ST_GeomFromText(text) •ST_Equals(geom, geom) •ST_Contains(geom, geom) •ST_Disjoint(geom, geom) •ST_Intersects(geom, geom) •ST_Distance_Sphere(geom, geom) •and more…
  • 9. Luigi Dell’Aquila @ldellaquila Prague, 20-21 October 2016 Our Data Model CREATE CLASS POI EXTENDS V CREATE PROPERTY POI.location EMBEDDED OPoint CREATE INDEX POI.location on POI(location) SPATIAL ENGINE LUCENE CREATE CLASS Natural EXTENDS V CREATE PROPERTY Natural.location EMBEDDED OPolygon CREATE INDEX Natural.location on Natural(location) SPATIAL ENGINE LUCENE CREATE CLASS Person EXTENDS V CREATE PROPERTY Person.location EMBEDDED OPoint CREATE CLASS FriendOf EXTENDS E
  • 10. Luigi Dell’Aquila @ldellaquila Prague, 20-21 October 2016 Our Data Source (WKT) WKT,osm_id,name,type "POINT (14.4641804 50.0972109)",24569342,"Invalidovna, Metro B",station "POINT (14.4739792 50.1036789)",24569358,"Palmovka, Metro B",station "POINT (14.4921863 50.1062907)",24569412,"Českomoravská, Metro B",station
  • 11. Luigi Dell’Aquila @ldellaquila Prague, 20-21 October 2016 Now let’s import data! > npm init > npm install orientjs > npm install fast-csv > touch index.js import files http://www.mapcruzin.com/free-czech-republic-maps.htm (convert to WKT using QGis)
  • 12. Luigi Dell’Aquila @ldellaquila Prague, 20-21 October 2016 Dependencies var fs = require("fs")
 var ODatabase = require("orientjs").ODatabase
 var csv = require("fast-csv")
  • 13. Luigi Dell’Aquila @ldellaquila Prague, 20-21 October 2016 Read from CSV var stream = fs.createReadStream("data/poland-poi.csv");
 
 var csvStream = csv.parse({headers: true})
 .on("data", function(data){
 console.log(data)
 })
 .on("end", function(){
 console.log("Done!")
 });
 
 stream.pipe(csvStream); 

  • 14. Luigi Dell’Aquila @ldellaquila Prague, 20-21 October 2016 DB connection var db = new ODatabase({
 host: "localhost",
 port: 2424,
 username: "admin",
 password: "admin",
 name: "geo"
 }) db.open().then(function(){
 } 

  • 15. Luigi Dell’Aquila @ldellaquila Prague, 20-21 October 2016 Insert var insertElement = function(data){
 db.insert().into(className).set(
 {
 name: data.name,
 type: data.type,
 location: db.rawExpression("ST_GeomFromText('"+data.WKT+"')")
 }
 ).one().then(function(){})
 } 

  • 16. Luigi Dell’Aquila @ldellaquila Prague, 20-21 October 2016 Is it done? Not yet :-( Node.js… asynchronous… promises… Final version: https://github.com/luigidellaquila/wkt-to-orient
  • 17. Luigi Dell’Aquila @ldellaquila Prague, 20-21 October 2016 Querying geo data We are here: (50.10902, 14.5831653) (lat, lon)
  • 19. Luigi Dell’Aquila @ldellaquila Prague, 20-21 October 2016 Clone the scaffolding > git clone https://github.com/luigidellaquila/geospatial-demo > git checkout warsaw_demo_step0 > cd geospatial-demo > npm install (it’s a clone of https://github.com/angular/quickstart) > npm start
  • 20. Luigi Dell’Aquila @ldellaquila Prague, 20-21 October 2016 Clone the scaffolding > git clone https://github.com/luigidellaquila/geospatial-demo > git checkout warsaw_demo_step0 > cd geospatial-demo > npm install (it’s a clone of https://github.com/angular/quickstart) > npm start > cd <orientdb-home>/www > ln -s <quickstart-path> > tsc -w
  • 21. Luigi Dell’Aquila @ldellaquila Prague, 20-21 October 2016 We need Google Maps <script src=“https://maps.googleapis.com/maps/api/js?key=API_KEY"
 async defer></script>
  • 22. Luigi Dell’Aquila @ldellaquila Prague, 20-21 October 2016 Let’s display a map (app.html) <div class=“container">
 <div class="row">
 <div class="col-md-12" id="map" style=“height:600px"></div>
 </div>
 </div>
  • 23. Luigi Dell’Aquila @ldellaquila Prague, 20-21 October 2016 Draw the map drawMap(){
 var controller = this;
 let mapProp = {
 center: new google.maps.LatLng(52.231807953759706, 21.013154983520508),
 zoom: 16,
 mapTypeId: google.maps.MapTypeId.ROADMAP
 };
 
 controller.map = new google.maps.Map(document.getElementById("map"), mapProp);
 controller.map.addListener("click", function(point: any){
 controller.zone.run(()=> {
 controller.lat = point.latLng.lat();
 controller.lon = point.latLng.lng();
 });
 });
 }
  • 24. Luigi Dell’Aquila @ldellaquila Prague, 20-21 October 2016 Create a Person createPerson(): void{
 var location = {
 // the location object
 }
 
 var queryString = ””; // OrientDB statement
 
 this.orient.command( queryString, (result) => { /* Success callback */ }, (error) => { /* Error callback */ } );
 }

  • 25. Luigi Dell’Aquila @ldellaquila Prague, 20-21 October 2016 Create a Person createPerson(): void{
 var location = {
 "@class": "OPoint",
 coordinates: [this.lon, this.lat]
 }
 
 var queryString = ””; // OrientDB statement
 
 this.orient.command( queryString, (result) => { /* Success callback */ }, (error) => { /* Error callback */ } );}

  • 26. Luigi Dell’Aquila @ldellaquila Prague, 20-21 October 2016 Create a Person createPerson(): void{
 var location = {
 "@class": "OPoint",
 coordinates: [this.lon, this.lat]
 }
 
 var queryString = `insert into Person 
 set name = '${this.personName}', 
 location = ${JSON.stringify(location)}`;
 
 this.orient.command( queryString, (result) => { /* Success callback */ }, (error) => { /* Error callback */ } );
 }

  • 27. Luigi Dell’Aquila @ldellaquila Prague, 20-21 October 2016 Create a Person createPerson(): void{
 var location = {
 "@class": "OPoint",
 coordinates: [this.lon, this.lat]
 }
 
 var queryString = `insert into Person 
 set name = '${this.personName}', 
 location = ${JSON.stringify(location)}`;
 
 this.orient.command( queryString, (res) => {
 let body = res.json();
 let person = body.result[0];
 this.addPersonToMap(person)
 }, (e) => { console.log(e) });
 }

  • 28. Luigi Dell’Aquila @ldellaquila Prague, 20-21 October 2016 Add Person Vertex to Orient via REST API command(statement: string, success: (data: any) => void, error: (err: any) => void): void{
 var url = this.url + "sql/-/-1" 
 var headers = new Headers();
 headers.append("Authorization", "Basic " + btoa(this.username+":"+this.password));
 
 this.http.post( // HTTP POST
 url, // the URL
 JSON.stringify({
 "command": statement // the SQL command
 }),
 {headers: headers} // the authentication data
 ).toPromise()
 .then(success)
 .catch(error);
 }
  • 29. Luigi Dell’Aquila @ldellaquila Prague, 20-21 October 2016 Add Person to the Map addPersonToMap(personData:any){
 let location = personData.location;
 let coordinates = location.coordinates;
 let controller = this;
 let marker = new google.maps.Marker({
 position: {lat:coordinates[1], lng:coordinates[0]},
 map: this.map,
 title: personData.name,
 rid: personData["@rid"]
 });
 google.maps.event.addListener(marker, 'click', function() {
 controller.onMarkerClick(marker);
 });
 }
  • 30. Luigi Dell’Aquila @ldellaquila Prague, 20-21 October 2016 Add an edge between people (FriendOf) createEdge(from:any, to:any): void{
 this.orient.command(
 `create edge FriendOf from ${from.rid} to ${to.rid}`,
 (x)=>{console.log(x)},
 (x)=>{console.log(x)}
 )
 this.addEdgeBetweenMarkersToMap(from, to);
 }