SlideShare a Scribd company logo
1 of 31
Download to read offline
Geospatial Graphs made easy
with
#OrientDB - @ldellaquila
Luigi Dell’Aquila
Core Developer and Director of Consulting
OrientDB LTD
Twitter: @ldellaquila
http://www.orientdb.com
#OrientDB - @ldellaquila
Summary
• Getting started with 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
#OrientDB - @ldellaquila
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
#OrientDB - @ldellaquila
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
#OrientDB - @ldellaquila
OrientDB GeoSpatial Classes
• OPoint
• OLine
• OPolygon
• OMultiPoint
• OMultiline
• OMultiPlygon
#OrientDB - @ldellaquila
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…
#OrientDB - @ldellaquila
Our goal
#OrientDB - @ldellaquila
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
#OrientDB - @ldellaquila
Now let’s import data!
> npm init
> npm install orientjs
> npm install fast-csv
> touch index.js
import files
http://www.mapcruzin.com/free-poland-maps.htm
(convert to WKT using QGis)
#OrientDB - @ldellaquila
Dependencies
var fs = require("fs")

var ODatabase = require("orientjs").ODatabase

var csv = require("fast-csv")
#OrientDB - @ldellaquila
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);


#OrientDB - @ldellaquila
DB connection
var db = new ODatabase({

host: "localhost",

port: 2424,

username: "admin",

password: "admin",

name: "geo"

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

}


#OrientDB - @ldellaquila
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(){})

}


#OrientDB - @ldellaquila
Is it done?
Not yet :-(
Node.js… asynchronous… promises…
Final version:
https://github.com/luigidellaquila/wkt-to-orient
#OrientDB - @ldellaquila
Querying geo data
We are here:
(52.231807953759706, 21.013154983520508)
(lat, lon)
#OrientDB - @ldellaquila
Front-End!
#OrientDB - @ldellaquila
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
#OrientDB - @ldellaquila
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
#OrientDB - @ldellaquila
We need Google Maps
<script src=“https://maps.googleapis.com/maps/api/js?key=API_KEY"

async defer></script>
#OrientDB - @ldellaquila
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>
#OrientDB - @ldellaquila
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();

});

});

}
#OrientDB - @ldellaquila
Create a Person
createPerson(): void{

var location = {

// the location object

}



var queryString = ””; // OrientDB statement



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

}

#OrientDB - @ldellaquila
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 */ }
);}

#OrientDB - @ldellaquila
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 */ }
);

}

#OrientDB - @ldellaquila
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) });

}

#OrientDB - @ldellaquila
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);

}
#OrientDB - @ldellaquila
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);

});

}
#OrientDB - @ldellaquila
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);

}
#OrientDB - @ldellaquila
Query the
Geospatial Graph
(DEMO)
#OrientDB - @ldellaquila
Thank you!

More Related Content

What's hot

Multi-Model Data Query Languages and Processing Paradigms
Multi-Model Data Query Languages and Processing ParadigmsMulti-Model Data Query Languages and Processing Paradigms
Multi-Model Data Query Languages and Processing ParadigmsJiaheng Lu
 
A Graph Database That Scales - ArangoDB 3.7 Release Webinar
A Graph Database That Scales - ArangoDB 3.7 Release WebinarA Graph Database That Scales - ArangoDB 3.7 Release Webinar
A Graph Database That Scales - ArangoDB 3.7 Release WebinarArangoDB Database
 
Introduction to Spark SQL training workshop
Introduction to Spark SQL training workshopIntroduction to Spark SQL training workshop
Introduction to Spark SQL training workshop(Susan) Xinh Huynh
 
Apache Calcite (a tutorial given at BOSS '21)
Apache Calcite (a tutorial given at BOSS '21)Apache Calcite (a tutorial given at BOSS '21)
Apache Calcite (a tutorial given at BOSS '21)Julian Hyde
 
ODTUG Webcast - Thinking Clearly about XML
ODTUG Webcast - Thinking Clearly about XMLODTUG Webcast - Thinking Clearly about XML
ODTUG Webcast - Thinking Clearly about XMLMarco Gralike
 
Masterless Distributed Computing with Riak Core - EUC 2010
Masterless Distributed Computing with Riak Core - EUC 2010Masterless Distributed Computing with Riak Core - EUC 2010
Masterless Distributed Computing with Riak Core - EUC 2010Rusty Klophaus
 
Works with persistent graphs using OrientDB
Works with persistent graphs using OrientDB Works with persistent graphs using OrientDB
Works with persistent graphs using OrientDB graphdevroom
 
Query mechanisms for NoSQL databases
Query mechanisms for NoSQL databasesQuery mechanisms for NoSQL databases
Query mechanisms for NoSQL databasesArangoDB Database
 
Apache Olingo - ApacheCon Denver 2014
Apache Olingo - ApacheCon Denver 2014Apache Olingo - ApacheCon Denver 2014
Apache Olingo - ApacheCon Denver 2014Stephan Klevenz
 
Miracle Open World 2011 - XML Index Strategies
Miracle Open World 2011  -  XML Index StrategiesMiracle Open World 2011  -  XML Index Strategies
Miracle Open World 2011 - XML Index StrategiesMarco Gralike
 
Milton Webdav Presentation for Linagora
Milton Webdav Presentation for LinagoraMilton Webdav Presentation for Linagora
Milton Webdav Presentation for LinagoraBrad McEvoy
 
Jakarta EE Meets NoSQL in the Cloud Age [DEV6109]
Jakarta EE Meets NoSQL in the Cloud Age [DEV6109]Jakarta EE Meets NoSQL in the Cloud Age [DEV6109]
Jakarta EE Meets NoSQL in the Cloud Age [DEV6109]Otávio Santana
 
Eclipse JNoSQL: One API to Many NoSQL Databases - BYOL [HOL5998]
Eclipse JNoSQL: One API to Many NoSQL Databases - BYOL [HOL5998]Eclipse JNoSQL: One API to Many NoSQL Databases - BYOL [HOL5998]
Eclipse JNoSQL: One API to Many NoSQL Databases - BYOL [HOL5998]Otávio Santana
 
Fast federated SQL with Apache Calcite
Fast federated SQL with Apache CalciteFast federated SQL with Apache Calcite
Fast federated SQL with Apache CalciteChris Baynes
 
Rupy2012 ArangoDB Workshop Part1
Rupy2012 ArangoDB Workshop Part1Rupy2012 ArangoDB Workshop Part1
Rupy2012 ArangoDB Workshop Part1ArangoDB Database
 
Alternator webinar september 2019
Alternator webinar   september 2019Alternator webinar   september 2019
Alternator webinar september 2019Nadav Har'El
 
Why we love ArangoDB. The hunt for the right NosQL Database
Why we love ArangoDB. The hunt for the right NosQL DatabaseWhy we love ArangoDB. The hunt for the right NosQL Database
Why we love ArangoDB. The hunt for the right NosQL DatabaseAndreas Jung
 
The power of datomic
The power of datomicThe power of datomic
The power of datomicKonrad Szydlo
 

What's hot (20)

Multi-Model Data Query Languages and Processing Paradigms
Multi-Model Data Query Languages and Processing ParadigmsMulti-Model Data Query Languages and Processing Paradigms
Multi-Model Data Query Languages and Processing Paradigms
 
A Graph Database That Scales - ArangoDB 3.7 Release Webinar
A Graph Database That Scales - ArangoDB 3.7 Release WebinarA Graph Database That Scales - ArangoDB 3.7 Release Webinar
A Graph Database That Scales - ArangoDB 3.7 Release Webinar
 
Spark SQL
Spark SQLSpark SQL
Spark SQL
 
Introduction to Spark SQL training workshop
Introduction to Spark SQL training workshopIntroduction to Spark SQL training workshop
Introduction to Spark SQL training workshop
 
Apache Calcite (a tutorial given at BOSS '21)
Apache Calcite (a tutorial given at BOSS '21)Apache Calcite (a tutorial given at BOSS '21)
Apache Calcite (a tutorial given at BOSS '21)
 
ODTUG Webcast - Thinking Clearly about XML
ODTUG Webcast - Thinking Clearly about XMLODTUG Webcast - Thinking Clearly about XML
ODTUG Webcast - Thinking Clearly about XML
 
Masterless Distributed Computing with Riak Core - EUC 2010
Masterless Distributed Computing with Riak Core - EUC 2010Masterless Distributed Computing with Riak Core - EUC 2010
Masterless Distributed Computing with Riak Core - EUC 2010
 
Works with persistent graphs using OrientDB
Works with persistent graphs using OrientDB Works with persistent graphs using OrientDB
Works with persistent graphs using OrientDB
 
Query mechanisms for NoSQL databases
Query mechanisms for NoSQL databasesQuery mechanisms for NoSQL databases
Query mechanisms for NoSQL databases
 
Apache Olingo - ApacheCon Denver 2014
Apache Olingo - ApacheCon Denver 2014Apache Olingo - ApacheCon Denver 2014
Apache Olingo - ApacheCon Denver 2014
 
Miracle Open World 2011 - XML Index Strategies
Miracle Open World 2011  -  XML Index StrategiesMiracle Open World 2011  -  XML Index Strategies
Miracle Open World 2011 - XML Index Strategies
 
Milton Webdav Presentation for Linagora
Milton Webdav Presentation for LinagoraMilton Webdav Presentation for Linagora
Milton Webdav Presentation for Linagora
 
Jakarta EE Meets NoSQL in the Cloud Age [DEV6109]
Jakarta EE Meets NoSQL in the Cloud Age [DEV6109]Jakarta EE Meets NoSQL in the Cloud Age [DEV6109]
Jakarta EE Meets NoSQL in the Cloud Age [DEV6109]
 
Eclipse JNoSQL: One API to Many NoSQL Databases - BYOL [HOL5998]
Eclipse JNoSQL: One API to Many NoSQL Databases - BYOL [HOL5998]Eclipse JNoSQL: One API to Many NoSQL Databases - BYOL [HOL5998]
Eclipse JNoSQL: One API to Many NoSQL Databases - BYOL [HOL5998]
 
Fast federated SQL with Apache Calcite
Fast federated SQL with Apache CalciteFast federated SQL with Apache Calcite
Fast federated SQL with Apache Calcite
 
Spark sql
Spark sqlSpark sql
Spark sql
 
Rupy2012 ArangoDB Workshop Part1
Rupy2012 ArangoDB Workshop Part1Rupy2012 ArangoDB Workshop Part1
Rupy2012 ArangoDB Workshop Part1
 
Alternator webinar september 2019
Alternator webinar   september 2019Alternator webinar   september 2019
Alternator webinar september 2019
 
Why we love ArangoDB. The hunt for the right NosQL Database
Why we love ArangoDB. The hunt for the right NosQL DatabaseWhy we love ArangoDB. The hunt for the right NosQL Database
Why we love ArangoDB. The hunt for the right NosQL Database
 
The power of datomic
The power of datomicThe power of datomic
The power of datomic
 

Similar to Geospatial Graphs made easy with OrientDB

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
 
GeeCON Prague 2016 - Geospatial Graphs made easy with OrientDB
GeeCON Prague 2016 - Geospatial Graphs made easy with OrientDBGeeCON Prague 2016 - Geospatial Graphs made easy with OrientDB
GeeCON Prague 2016 - Geospatial Graphs made easy with OrientDBLuigi Dell'Aquila
 
Hd insight programming
Hd insight programmingHd insight programming
Hd insight programmingCasear Chu
 
Geospatial Graphs made easy with OrientDB - Luigi Dell'Aquila - Codemotion Mi...
Geospatial Graphs made easy with OrientDB - Luigi Dell'Aquila - Codemotion Mi...Geospatial Graphs made easy with OrientDB - Luigi Dell'Aquila - Codemotion Mi...
Geospatial Graphs made easy with OrientDB - Luigi Dell'Aquila - Codemotion Mi...Codemotion
 
Geospatial Graphs made easy with OrientDB - Codemotion Milan 2016
Geospatial Graphs made easy with OrientDB - Codemotion Milan 2016Geospatial Graphs made easy with OrientDB - Codemotion Milan 2016
Geospatial Graphs made easy with OrientDB - Codemotion Milan 2016Luigi Dell'Aquila
 
OSCON 2011 CouchApps
OSCON 2011 CouchAppsOSCON 2011 CouchApps
OSCON 2011 CouchAppsBradley Holt
 
Full stack development with node and NoSQL - All Things Open - October 2017
Full stack development with node and NoSQL - All Things Open - October 2017Full stack development with node and NoSQL - All Things Open - October 2017
Full stack development with node and NoSQL - All Things Open - October 2017Matthew Groves
 
Full Stack Development with Node.js and NoSQL
Full Stack Development with Node.js and NoSQLFull Stack Development with Node.js and NoSQL
Full Stack Development with Node.js and NoSQLAll Things Open
 
CouchDB on Android
CouchDB on AndroidCouchDB on Android
CouchDB on AndroidSven Haiges
 
Crafting Evolvable Api Responses
Crafting Evolvable Api ResponsesCrafting Evolvable Api Responses
Crafting Evolvable Api Responsesdarrelmiller71
 
Solutions for bi-directional Integration between Oracle RDMBS & Apache Kafka
Solutions for bi-directional Integration between Oracle RDMBS & Apache KafkaSolutions for bi-directional Integration between Oracle RDMBS & Apache Kafka
Solutions for bi-directional Integration between Oracle RDMBS & Apache KafkaGuido Schmutz
 
Solutions for bi-directional integration between Oracle RDBMS and Apache Kafk...
Solutions for bi-directional integration between Oracle RDBMS and Apache Kafk...Solutions for bi-directional integration between Oracle RDBMS and Apache Kafk...
Solutions for bi-directional integration between Oracle RDBMS and Apache Kafk...confluent
 
MongoDB + Java - Everything you need to know
MongoDB + Java - Everything you need to know MongoDB + Java - Everything you need to know
MongoDB + Java - Everything you need to know Norberto Leite
 
Mongo+java (1)
Mongo+java (1)Mongo+java (1)
Mongo+java (1)MongoDB
 
Webエンジニアから見たiOS5
Webエンジニアから見たiOS5Webエンジニアから見たiOS5
Webエンジニアから見たiOS5Satoshi Asano
 
Solutions for bi-directional integration between Oracle RDBMS & Apache Kafka
Solutions for bi-directional integration between Oracle RDBMS & Apache KafkaSolutions for bi-directional integration between Oracle RDBMS & Apache Kafka
Solutions for bi-directional integration between Oracle RDBMS & Apache KafkaGuido Schmutz
 

Similar to Geospatial Graphs made easy with OrientDB (20)

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
 
GeeCON Prague 2016 - Geospatial Graphs made easy with OrientDB
GeeCON Prague 2016 - Geospatial Graphs made easy with OrientDBGeeCON Prague 2016 - Geospatial Graphs made easy with OrientDB
GeeCON Prague 2016 - Geospatial Graphs made easy with OrientDB
 
Hd insight programming
Hd insight programmingHd insight programming
Hd insight programming
 
Geospatial Graphs made easy with OrientDB - Luigi Dell'Aquila - Codemotion Mi...
Geospatial Graphs made easy with OrientDB - Luigi Dell'Aquila - Codemotion Mi...Geospatial Graphs made easy with OrientDB - Luigi Dell'Aquila - Codemotion Mi...
Geospatial Graphs made easy with OrientDB - Luigi Dell'Aquila - Codemotion Mi...
 
Geospatial Graphs made easy with OrientDB - Codemotion Milan 2016
Geospatial Graphs made easy with OrientDB - Codemotion Milan 2016Geospatial Graphs made easy with OrientDB - Codemotion Milan 2016
Geospatial Graphs made easy with OrientDB - Codemotion Milan 2016
 
OSCON 2011 CouchApps
OSCON 2011 CouchAppsOSCON 2011 CouchApps
OSCON 2011 CouchApps
 
Full stack development with node and NoSQL - All Things Open - October 2017
Full stack development with node and NoSQL - All Things Open - October 2017Full stack development with node and NoSQL - All Things Open - October 2017
Full stack development with node and NoSQL - All Things Open - October 2017
 
Full Stack Development with Node.js and NoSQL
Full Stack Development with Node.js and NoSQLFull Stack Development with Node.js and NoSQL
Full Stack Development with Node.js and NoSQL
 
CouchDB on Android
CouchDB on AndroidCouchDB on Android
CouchDB on Android
 
Dartprogramming
DartprogrammingDartprogramming
Dartprogramming
 
Crafting Evolvable Api Responses
Crafting Evolvable Api ResponsesCrafting Evolvable Api Responses
Crafting Evolvable Api Responses
 
Doctrine and NoSQL
Doctrine and NoSQLDoctrine and NoSQL
Doctrine and NoSQL
 
Requery overview
Requery overviewRequery overview
Requery overview
 
Solutions for bi-directional Integration between Oracle RDMBS & Apache Kafka
Solutions for bi-directional Integration between Oracle RDMBS & Apache KafkaSolutions for bi-directional Integration between Oracle RDMBS & Apache Kafka
Solutions for bi-directional Integration between Oracle RDMBS & Apache Kafka
 
Solutions for bi-directional integration between Oracle RDBMS and Apache Kafk...
Solutions for bi-directional integration between Oracle RDBMS and Apache Kafk...Solutions for bi-directional integration between Oracle RDBMS and Apache Kafk...
Solutions for bi-directional integration between Oracle RDBMS and Apache Kafk...
 
MongoDB + Java - Everything you need to know
MongoDB + Java - Everything you need to know MongoDB + Java - Everything you need to know
MongoDB + Java - Everything you need to know
 
Mongo+java (1)
Mongo+java (1)Mongo+java (1)
Mongo+java (1)
 
Webエンジニアから見たiOS5
Webエンジニアから見たiOS5Webエンジニアから見たiOS5
Webエンジニアから見たiOS5
 
Doctrine for NoSQL
Doctrine for NoSQLDoctrine for NoSQL
Doctrine for NoSQL
 
Solutions for bi-directional integration between Oracle RDBMS & Apache Kafka
Solutions for bi-directional integration between Oracle RDBMS & Apache KafkaSolutions for bi-directional integration between Oracle RDBMS & Apache Kafka
Solutions for bi-directional integration between Oracle RDBMS & Apache Kafka
 

More from Luigi Dell'Aquila

Geospatial Graphs made easy with OrientDB - Codemotion Spain
Geospatial Graphs made easy with OrientDB - Codemotion SpainGeospatial Graphs made easy with OrientDB - Codemotion Spain
Geospatial Graphs made easy with OrientDB - Codemotion SpainLuigi Dell'Aquila
 
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
 
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 - Time Series and Event Sequences - Codemotion Milan 2014
OrientDB - Time Series and Event Sequences - Codemotion Milan 2014OrientDB - Time Series and Event Sequences - Codemotion Milan 2014
OrientDB - Time Series and Event Sequences - Codemotion Milan 2014Luigi 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
 

More from Luigi Dell'Aquila (11)

Geospatial Graphs made easy with OrientDB - Codemotion Spain
Geospatial Graphs made easy with OrientDB - Codemotion SpainGeospatial Graphs made easy with OrientDB - Codemotion Spain
Geospatial Graphs made easy with OrientDB - Codemotion Spain
 
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
 
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 - Time Series and Event Sequences - Codemotion Milan 2014
OrientDB - Time Series and Event Sequences - Codemotion Milan 2014OrientDB - Time Series and Event Sequences - Codemotion Milan 2014
OrientDB - Time Series and Event Sequences - Codemotion Milan 2014
 
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
 

Recently uploaded

Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
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
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
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
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 

Recently uploaded (20)

Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
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
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
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
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 

Geospatial Graphs made easy with OrientDB

  • 2. #OrientDB - @ldellaquila Luigi Dell’Aquila Core Developer and Director of Consulting OrientDB LTD Twitter: @ldellaquila http://www.orientdb.com
  • 3. #OrientDB - @ldellaquila Summary • Getting started with 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
  • 4. #OrientDB - @ldellaquila 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
  • 5. #OrientDB - @ldellaquila 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
  • 6. #OrientDB - @ldellaquila OrientDB GeoSpatial Classes • OPoint • OLine • OPolygon • OMultiPoint • OMultiline • OMultiPlygon
  • 7. #OrientDB - @ldellaquila 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. #OrientDB - @ldellaquila 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. #OrientDB - @ldellaquila Now let’s import data! > npm init > npm install orientjs > npm install fast-csv > touch index.js import files http://www.mapcruzin.com/free-poland-maps.htm (convert to WKT using QGis)
  • 11. #OrientDB - @ldellaquila Dependencies var fs = require("fs")
 var ODatabase = require("orientjs").ODatabase
 var csv = require("fast-csv")
  • 12. #OrientDB - @ldellaquila 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); 

  • 13. #OrientDB - @ldellaquila DB connection var db = new ODatabase({
 host: "localhost",
 port: 2424,
 username: "admin",
 password: "admin",
 name: "geo"
 }) db.open().then(function(){
 } 

  • 14. #OrientDB - @ldellaquila 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(){})
 } 

  • 15. #OrientDB - @ldellaquila Is it done? Not yet :-( Node.js… asynchronous… promises… Final version: https://github.com/luigidellaquila/wkt-to-orient
  • 16. #OrientDB - @ldellaquila Querying geo data We are here: (52.231807953759706, 21.013154983520508) (lat, lon)
  • 18. #OrientDB - @ldellaquila 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
  • 19. #OrientDB - @ldellaquila 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
  • 20. #OrientDB - @ldellaquila We need Google Maps <script src=“https://maps.googleapis.com/maps/api/js?key=API_KEY"
 async defer></script>
  • 21. #OrientDB - @ldellaquila 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>
  • 22. #OrientDB - @ldellaquila 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();
 });
 });
 }
  • 23. #OrientDB - @ldellaquila Create a Person createPerson(): void{
 var location = {
 // the location object
 }
 
 var queryString = ””; // OrientDB statement
 
 this.orient.command( queryString, (result) => { /* Success callback */ }, (error) => { /* Error callback */ } );
 }

  • 24. #OrientDB - @ldellaquila 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 */ } );}

  • 25. #OrientDB - @ldellaquila 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 */ } );
 }

  • 26. #OrientDB - @ldellaquila 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) });
 }

  • 27. #OrientDB - @ldellaquila 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);
 }
  • 28. #OrientDB - @ldellaquila 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);
 });
 }
  • 29. #OrientDB - @ldellaquila 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);
 }
  • 30. #OrientDB - @ldellaquila Query the Geospatial Graph (DEMO)