SlideShare une entreprise Scribd logo
1  sur  31
Télécharger pour lire hors ligne
GeoSpatial Graphs
made easy with
Luigi Dell’Aquila
MADRID · NOV 18-19 · 2016
Luigi Dell’Aquila @ldellaquila Madrid - Nov 18-19 2016
Luigi Dell’Aquila
Core Developer and Director of Consulting
OrientDB LTD
Twitter: @ldellaquila
http://www.orientdb.com
Luigi Dell’Aquila @ldellaquila Madrid - Nov 18-19 2016
Our goal
Luigi Dell’Aquila @ldellaquila Madrid - Nov 18-19 2016
Summary
•What is OrientDB
•OrientDB GeoSpatial API
•Importing Geo data (Java and/or Node.js)
•Querying Geo data (OrientDB Studio)
•Displaying Geo data (Angular2, Google Maps)
•Adding Relationships - graph data
•Graph + Spatial queries
Luigi Dell’Aquila @ldellaquila Madrid - Nov 18-19 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 Madrid - Nov 18-19 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 Madrid - Nov 18-19 2016
OrientDB GeoSpatial Classes
•OPoint
•OLine
•OPolygon
•OMultiPoint
•OMultiline
•OMultiPlygon
Luigi Dell’Aquila @ldellaquila Madrid - Nov 18-19 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 Madrid - Nov 18-19 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 Madrid - Nov 18-19 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 Madrid - Nov 18-19 2016
Now let’s import data!
Let’s do it in Java
you can download some Geo files from
http://www.mapcruzin.com/free-spain-maps.htm
and convert them to WKT using QGis (www.qgis.org)
Luigi Dell’Aquila @ldellaquila Madrid - Nov 18-19 2016
Maven Dependencies
<dependency>

<groupId>org.apache.commons</groupId>

<artifactId>commons-csv</artifactId>

<version>1.2</version>

</dependency>



<dependency>

<groupId>com.orientechnologies</groupId>

<artifactId>orientdb-graphdb</artifactId>

<version>2.2.13</version>

</dependency>
Luigi Dell’Aquila @ldellaquila Madrid - Nov 18-19 2016
Read from CSV
Reader reader = new FileReader("/path/to/poi_file.csv");

CSVParser parser = CSVFormat.DEFAULT.parse(reader);

Iterator<CSVRecord> iterator = parser.iterator();

iterator.next(); //discard the header




while(iterator.hasNext()){ //read each row

importRecord(iterator.next()); 

}


Luigi Dell’Aquila @ldellaquila Madrid - Nov 18-19 2016
OrientDB connection
Reader reader = new FileReader("/path/to/poi_file.csv");

CSVParser parser = CSVFormat.DEFAULT.parse(reader);

Iterator<CSVRecord> iterator = parser.iterator();

iterator.next(); //discard the header


OrientGraph graph =
new OrientGraph("remote:localhost/testdb", "admin", "admin");

while(iterator.hasNext()){ //read each row

importRecord(iterator.next(), graph);

}


graph.shutdown();
Luigi Dell’Aquila @ldellaquila Madrid - Nov 18-19 2016
importRecord()
void importRecord(CSVRecord record, OrientGraph graph) {

String wkt = record.get(0);

String name = record.get(2);

String type = record.get(3);



graph.command(new OCommandSQL(

"insert into Natural " +

"set name = ?, type = ?, " +

"location = ST_GeomFromText(?)"))

.execute(name, type, wkt);

}
Luigi Dell’Aquila @ldellaquila Madrid - Nov 18-19 2016
Querying geo data
We are here:
(40.399640, -3.8375544)
(lat, lon)
Luigi Dell’Aquila @ldellaquila Madrid - Nov 18-19 2016
Front-End!
Luigi Dell’Aquila @ldellaquila Madrid - Nov 18-19 2016
Clone the scaffolding
> git clone https://github.com/luigidellaquila/geospatial-demo
> cd geospatial-demo
> npm install
(it’s a clone of https://github.com/angular/quickstart)
> npm start
Luigi Dell’Aquila @ldellaquila Madrid - Nov 18-19 2016
Clone the scaffolding
> git clone https://github.com/luigidellaquila/geospatial-demo
> 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 Madrid - Nov 18-19 2016
We need Google Maps
<script src=“https://maps.googleapis.com/maps/api/js?key=API_KEY"

async defer></script>
Luigi Dell’Aquila @ldellaquila Madrid - Nov 18-19 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 Madrid - Nov 18-19 2016
Draw the map
drawMap(){

var controller = this;

let mapProp = {

center: new google.maps.LatLng(40.399640, -3.8375544),

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 Madrid - Nov 18-19 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 Madrid - Nov 18-19 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 Madrid - Nov 18-19 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 Madrid - Nov 18-19 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 Madrid - Nov 18-19 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 Madrid - Nov 18-19 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 Madrid - Nov 18-19 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);

}
Luigi Dell’Aquila @ldellaquila Madrid - Nov 18-19 2016
Query the
Geospatial Graph
(DEMO)
Luigi Dell’Aquila @ldellaquila Madrid - Nov 18-19 2016
Thank you!

Contenu connexe

Tendances

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
 
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
 
Utilising the data attribute
Utilising the data attributeUtilising the data attribute
Utilising the data attributeRichard Martens
 
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
 
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
 
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
 
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
 

Tendances (10)

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
 
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
 
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
 
Utilising the data attribute
Utilising the data attributeUtilising the data attribute
Utilising the data attribute
 
Spark Your Legacy (Spark Summit 2016)
Spark Your Legacy (Spark Summit 2016)Spark Your Legacy (Spark Summit 2016)
Spark Your Legacy (Spark Summit 2016)
 
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
 
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
 
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?
 

En vedette

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
 
How Graph Databases started the Multi Model revolution
How Graph Databases started the Multi Model revolutionHow Graph Databases started the Multi Model revolution
How Graph Databases started the Multi Model revolutionLuca Garulli
 
OrientDB & Hazelcast: In-Memory Distributed Graph Database
 OrientDB & Hazelcast: In-Memory Distributed Graph Database OrientDB & Hazelcast: In-Memory Distributed Graph Database
OrientDB & Hazelcast: In-Memory Distributed Graph DatabaseHazelcast
 
OrientDB the graph database
OrientDB the graph databaseOrientDB the graph database
OrientDB the graph databaseartem_orobets
 
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
 
Time Series With OrientDB - Fosdem 2015
Time Series With OrientDB - Fosdem 2015Time Series With OrientDB - Fosdem 2015
Time Series With OrientDB - Fosdem 2015wolf4ood
 
OrientDB, the fastest document-based graph database @ Confoo 2014 in Montreal...
OrientDB, the fastest document-based graph database @ Confoo 2014 in Montreal...OrientDB, the fastest document-based graph database @ Confoo 2014 in Montreal...
OrientDB, the fastest document-based graph database @ Confoo 2014 in Montreal...Alessandro Nadalin
 
OrientDB introduction - NoSQL
OrientDB introduction - NoSQLOrientDB introduction - NoSQL
OrientDB introduction - NoSQLLuca Garulli
 
OrientDB for real & Web App development
OrientDB for real & Web App developmentOrientDB for real & Web App development
OrientDB for real & Web App developmentLuca Garulli
 
OrientDB vs Neo4j - Comparison of query/speed/functionality
OrientDB vs Neo4j - Comparison of query/speed/functionalityOrientDB vs Neo4j - Comparison of query/speed/functionality
OrientDB vs Neo4j - Comparison of query/speed/functionalityCurtis Mosters
 

En vedette (11)

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
 
How Graph Databases started the Multi Model revolution
How Graph Databases started the Multi Model revolutionHow Graph Databases started the Multi Model revolution
How Graph Databases started the Multi Model revolution
 
OrientDB & Hazelcast: In-Memory Distributed Graph Database
 OrientDB & Hazelcast: In-Memory Distributed Graph Database OrientDB & Hazelcast: In-Memory Distributed Graph Database
OrientDB & Hazelcast: In-Memory Distributed Graph Database
 
OrientDB the graph database
OrientDB the graph databaseOrientDB the graph database
OrientDB the graph database
 
OrientDB
OrientDBOrientDB
OrientDB
 
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
 
Time Series With OrientDB - Fosdem 2015
Time Series With OrientDB - Fosdem 2015Time Series With OrientDB - Fosdem 2015
Time Series With OrientDB - Fosdem 2015
 
OrientDB, the fastest document-based graph database @ Confoo 2014 in Montreal...
OrientDB, the fastest document-based graph database @ Confoo 2014 in Montreal...OrientDB, the fastest document-based graph database @ Confoo 2014 in Montreal...
OrientDB, the fastest document-based graph database @ Confoo 2014 in Montreal...
 
OrientDB introduction - NoSQL
OrientDB introduction - NoSQLOrientDB introduction - NoSQL
OrientDB introduction - NoSQL
 
OrientDB for real & Web App development
OrientDB for real & Web App developmentOrientDB for real & Web App development
OrientDB for real & Web App development
 
OrientDB vs Neo4j - Comparison of query/speed/functionality
OrientDB vs Neo4j - Comparison of query/speed/functionalityOrientDB vs Neo4j - Comparison of query/speed/functionality
OrientDB vs Neo4j - Comparison of query/speed/functionality
 

Similaire à Geospatial Graphs made easy with OrientDB - Codemotion Spain

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
 
How to separate frontend from a highload python project with no problems - Py...
How to separate frontend from a highload python project with no problems - Py...How to separate frontend from a highload python project with no problems - Py...
How to separate frontend from a highload python project with no problems - Py...Oleksandr Tarasenko
 
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
 
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
 
Getting Started with GraphQL && PHP
Getting Started with GraphQL && PHPGetting Started with GraphQL && PHP
Getting Started with GraphQL && PHPAndrew Rota
 
Geospatial Enhancements in MongoDB 2.4
Geospatial Enhancements in MongoDB 2.4Geospatial Enhancements in MongoDB 2.4
Geospatial Enhancements in MongoDB 2.4MongoDB
 
Codepot - Pig i Hive: szybkie wprowadzenie / Pig and Hive crash course
Codepot - Pig i Hive: szybkie wprowadzenie / Pig and Hive crash courseCodepot - Pig i Hive: szybkie wprowadzenie / Pig and Hive crash course
Codepot - Pig i Hive: szybkie wprowadzenie / Pig and Hive crash courseSages
 
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
 
OSMC 2009 | Icinga by Icinga Team
OSMC 2009 | Icinga by Icinga TeamOSMC 2009 | Icinga by Icinga Team
OSMC 2009 | Icinga by Icinga TeamNETWAYS
 
How to grow GraphQL and remove SQLAlchemy and REST API from a high-load Pytho...
How to grow GraphQL and remove SQLAlchemy and REST API from a high-load Pytho...How to grow GraphQL and remove SQLAlchemy and REST API from a high-load Pytho...
How to grow GraphQL and remove SQLAlchemy and REST API from a high-load Pytho...Oleksandr Tarasenko
 
Declarative Internal DSLs in Lua: A Game Changing Experience
Declarative Internal DSLs in Lua: A Game Changing ExperienceDeclarative Internal DSLs in Lua: A Game Changing Experience
Declarative Internal DSLs in Lua: A Game Changing ExperienceAlexander Gladysh
 
Perl on Amazon Elastic MapReduce
Perl on Amazon Elastic MapReducePerl on Amazon Elastic MapReduce
Perl on Amazon Elastic MapReducePedro Figueiredo
 
Icinga 2009 at OSMC
Icinga 2009 at OSMCIcinga 2009 at OSMC
Icinga 2009 at OSMCIcinga
 
Wprowadzenie do technologi Big Data i Apache Hadoop
Wprowadzenie do technologi Big Data i Apache HadoopWprowadzenie do technologi Big Data i Apache Hadoop
Wprowadzenie do technologi Big Data i Apache HadoopSages
 
Flask and Angular: An approach to build robust platforms
Flask and Angular:  An approach to build robust platformsFlask and Angular:  An approach to build robust platforms
Flask and Angular: An approach to build robust platformsAyush Sharma
 
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
 
Advanced CouchDB Rotterdam.rb July 2010
Advanced CouchDB Rotterdam.rb July 2010Advanced CouchDB Rotterdam.rb July 2010
Advanced CouchDB Rotterdam.rb July 2010Sander van de Graaf
 

Similaire à Geospatial Graphs made easy with OrientDB - Codemotion Spain (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
 
How to separate frontend from a highload python project with no problems - Py...
How to separate frontend from a highload python project with no problems - Py...How to separate frontend from a highload python project with no problems - Py...
How to separate frontend from a highload python project with no problems - Py...
 
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
 
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
 
Getting Started with GraphQL && PHP
Getting Started with GraphQL && PHPGetting Started with GraphQL && PHP
Getting Started with GraphQL && PHP
 
Geospatial Enhancements in MongoDB 2.4
Geospatial Enhancements in MongoDB 2.4Geospatial Enhancements in MongoDB 2.4
Geospatial Enhancements in MongoDB 2.4
 
Codepot - Pig i Hive: szybkie wprowadzenie / Pig and Hive crash course
Codepot - Pig i Hive: szybkie wprowadzenie / Pig and Hive crash courseCodepot - Pig i Hive: szybkie wprowadzenie / Pig and Hive crash course
Codepot - Pig i Hive: szybkie wprowadzenie / Pig and Hive crash course
 
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...
 
OSMC 2009 | Icinga by Icinga Team
OSMC 2009 | Icinga by Icinga TeamOSMC 2009 | Icinga by Icinga Team
OSMC 2009 | Icinga by Icinga Team
 
How to grow GraphQL and remove SQLAlchemy and REST API from a high-load Pytho...
How to grow GraphQL and remove SQLAlchemy and REST API from a high-load Pytho...How to grow GraphQL and remove SQLAlchemy and REST API from a high-load Pytho...
How to grow GraphQL and remove SQLAlchemy and REST API from a high-load Pytho...
 
Doctrine and NoSQL
Doctrine and NoSQLDoctrine and NoSQL
Doctrine and NoSQL
 
Doctrine for NoSQL
Doctrine for NoSQLDoctrine for NoSQL
Doctrine for NoSQL
 
Declarative Internal DSLs in Lua: A Game Changing Experience
Declarative Internal DSLs in Lua: A Game Changing ExperienceDeclarative Internal DSLs in Lua: A Game Changing Experience
Declarative Internal DSLs in Lua: A Game Changing Experience
 
Perl on Amazon Elastic MapReduce
Perl on Amazon Elastic MapReducePerl on Amazon Elastic MapReduce
Perl on Amazon Elastic MapReduce
 
Icinga 2009 at OSMC
Icinga 2009 at OSMCIcinga 2009 at OSMC
Icinga 2009 at OSMC
 
Wprowadzenie do technologi Big Data i Apache Hadoop
Wprowadzenie do technologi Big Data i Apache HadoopWprowadzenie do technologi Big Data i Apache Hadoop
Wprowadzenie do technologi Big Data i Apache Hadoop
 
Flask and Angular: An approach to build robust platforms
Flask and Angular:  An approach to build robust platformsFlask and Angular:  An approach to build robust platforms
Flask and Angular: An approach to build robust platforms
 
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...
 
Advanced CouchDB Rotterdam.rb July 2010
Advanced CouchDB Rotterdam.rb July 2010Advanced CouchDB Rotterdam.rb July 2010
Advanced CouchDB Rotterdam.rb July 2010
 

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
 
​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 (7)

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
 
​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

Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Strongerpanagenda
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Hiroshi SHIBATA
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationKnoldus Inc.
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterMydbops
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentPim van der Noll
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI AgeCprime
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesKari Kakkonen
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch TuesdayIvanti
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityIES VE
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...Wes McKinney
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPathCommunity
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 

Dernier (20)

Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog Presentation
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL Router
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI Age
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examples
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch Tuesday
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a reality
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to Hero
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 

Geospatial Graphs made easy with OrientDB - Codemotion Spain

  • 1. GeoSpatial Graphs made easy with Luigi Dell’Aquila MADRID · NOV 18-19 · 2016
  • 2. Luigi Dell’Aquila @ldellaquila Madrid - Nov 18-19 2016 Luigi Dell’Aquila Core Developer and Director of Consulting OrientDB LTD Twitter: @ldellaquila http://www.orientdb.com
  • 3. Luigi Dell’Aquila @ldellaquila Madrid - Nov 18-19 2016 Our goal
  • 4. Luigi Dell’Aquila @ldellaquila Madrid - Nov 18-19 2016 Summary •What is OrientDB •OrientDB GeoSpatial API •Importing Geo data (Java and/or 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 Madrid - Nov 18-19 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 Madrid - Nov 18-19 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 Madrid - Nov 18-19 2016 OrientDB GeoSpatial Classes •OPoint •OLine •OPolygon •OMultiPoint •OMultiline •OMultiPlygon
  • 8. Luigi Dell’Aquila @ldellaquila Madrid - Nov 18-19 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 Madrid - Nov 18-19 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 Madrid - Nov 18-19 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 Madrid - Nov 18-19 2016 Now let’s import data! Let’s do it in Java you can download some Geo files from http://www.mapcruzin.com/free-spain-maps.htm and convert them to WKT using QGis (www.qgis.org)
  • 12. Luigi Dell’Aquila @ldellaquila Madrid - Nov 18-19 2016 Maven Dependencies <dependency>
 <groupId>org.apache.commons</groupId>
 <artifactId>commons-csv</artifactId>
 <version>1.2</version>
 </dependency>
 
 <dependency>
 <groupId>com.orientechnologies</groupId>
 <artifactId>orientdb-graphdb</artifactId>
 <version>2.2.13</version>
 </dependency>
  • 13. Luigi Dell’Aquila @ldellaquila Madrid - Nov 18-19 2016 Read from CSV Reader reader = new FileReader("/path/to/poi_file.csv");
 CSVParser parser = CSVFormat.DEFAULT.parse(reader);
 Iterator<CSVRecord> iterator = parser.iterator();
 iterator.next(); //discard the header 
 
 while(iterator.hasNext()){ //read each row
 importRecord(iterator.next()); 
 } 

  • 14. Luigi Dell’Aquila @ldellaquila Madrid - Nov 18-19 2016 OrientDB connection Reader reader = new FileReader("/path/to/poi_file.csv");
 CSVParser parser = CSVFormat.DEFAULT.parse(reader);
 Iterator<CSVRecord> iterator = parser.iterator();
 iterator.next(); //discard the header 
 OrientGraph graph = new OrientGraph("remote:localhost/testdb", "admin", "admin");
 while(iterator.hasNext()){ //read each row
 importRecord(iterator.next(), graph);
 } 
 graph.shutdown();
  • 15. Luigi Dell’Aquila @ldellaquila Madrid - Nov 18-19 2016 importRecord() void importRecord(CSVRecord record, OrientGraph graph) {
 String wkt = record.get(0);
 String name = record.get(2);
 String type = record.get(3);
 
 graph.command(new OCommandSQL(
 "insert into Natural " +
 "set name = ?, type = ?, " +
 "location = ST_GeomFromText(?)"))
 .execute(name, type, wkt);
 }
  • 16. Luigi Dell’Aquila @ldellaquila Madrid - Nov 18-19 2016 Querying geo data We are here: (40.399640, -3.8375544) (lat, lon)
  • 17. Luigi Dell’Aquila @ldellaquila Madrid - Nov 18-19 2016 Front-End!
  • 18. Luigi Dell’Aquila @ldellaquila Madrid - Nov 18-19 2016 Clone the scaffolding > git clone https://github.com/luigidellaquila/geospatial-demo > cd geospatial-demo > npm install (it’s a clone of https://github.com/angular/quickstart) > npm start
  • 19. Luigi Dell’Aquila @ldellaquila Madrid - Nov 18-19 2016 Clone the scaffolding > git clone https://github.com/luigidellaquila/geospatial-demo > 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. Luigi Dell’Aquila @ldellaquila Madrid - Nov 18-19 2016 We need Google Maps <script src=“https://maps.googleapis.com/maps/api/js?key=API_KEY"
 async defer></script>
  • 21. Luigi Dell’Aquila @ldellaquila Madrid - Nov 18-19 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>
  • 22. Luigi Dell’Aquila @ldellaquila Madrid - Nov 18-19 2016 Draw the map drawMap(){
 var controller = this;
 let mapProp = {
 center: new google.maps.LatLng(40.399640, -3.8375544),
 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. Luigi Dell’Aquila @ldellaquila Madrid - Nov 18-19 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 */ } );
 }

  • 24. Luigi Dell’Aquila @ldellaquila Madrid - Nov 18-19 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 */ } );}

  • 25. Luigi Dell’Aquila @ldellaquila Madrid - Nov 18-19 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 */ } );
 }

  • 26. Luigi Dell’Aquila @ldellaquila Madrid - Nov 18-19 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) });
 }

  • 27. Luigi Dell’Aquila @ldellaquila Madrid - Nov 18-19 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);
 }
  • 28. Luigi Dell’Aquila @ldellaquila Madrid - Nov 18-19 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);
 });
 }
  • 29. Luigi Dell’Aquila @ldellaquila Madrid - Nov 18-19 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);
 }
  • 30. Luigi Dell’Aquila @ldellaquila Madrid - Nov 18-19 2016 Query the Geospatial Graph (DEMO)
  • 31. Luigi Dell’Aquila @ldellaquila Madrid - Nov 18-19 2016 Thank you!