SlideShare a Scribd company logo
1   #commands for adding spatial data!
 2   !
 3   #Take a look at the file first!
 4   #less parkcoord.json!
 5   !
 6   #get the file on the server!
 7   scp parkcoord.json 30bb1262b1364026855e358a649f171b@parks-spmongo.rhcloud.com:app-root/data!
 8   !
 9   #ssh into the machine!
10   ssh 30bb1262b1364026855e358a649f171b@parks-spmongo.rhcloud.com!
11   !
12   !
13   #import into mongo!
14   mongoimport -d parks -c parkpoints --type json --file app-root/data/parkcoord.json -h
 …   $OPENSHIFT_NOSQL_DB_HOST -u admin -p $OPENSHIFT_NOSQL_DB_PASSWORD!
15   !
16   #open the mongo shell!
17   mongo !
18   !
19   #build the index!
20   db.parkpoints.ensureIndex({"pos":"2d"});!
21   !
22   #Now some queries!
23   #simple spatial!
24   db.parkpoints.find({"pos" : { "$near" : [-37, 41]}});!
25   !
26   #spatial and text query using regex!
27   db.parkpoints.find( { Name : /lincoln/i, pos : { $near : [-37,41] }} );!
28   !
29   #geonear TODO!
30   db.runCommand({ geoNear : "parkpoints", near : [-37,41], num : 10 });!
31   !
32   !
33   #create a new collection from scratch!
34   db.createCollection("checkin");!
35   db.checkin.ensureIndex( { "pos" : "2d" } );!
36   !
37   #insert a new record!
38   db.checkin.insert({ "created" : new Date(), "Notes" : 'just landed', "pos" : [-76.7302 , 25.5332 ] })!
39   !   !
40   #quick query to make sure it worked!
41   db.checkin.find( { pos : { $near : [-37,41] } } )!
42   !
43   #add a second document closer to query point!
44   #this is an upsert - since we don't pass in the _id it creates a new record!
45   db.checkin.save({ created : new Date(), Notes: 'that was a big step', pos : [-37.7302 , 40.5332 ]});!
46   !
47   #one way to update original document!
48   myDoc = db.checkin.findOne({_id : ObjectId("50130d8ea8f6532e83026bc1")});!
49   myDoc.Notes = "really the landing";!
50   db.checkin.save(myDoc);!
51   !
52

More Related Content

ODT
Spatial script for MongoBoulder
PDF
Spatial script for my JS.Everywhere 2012
PDF
Script for Spatial Mongo
PDF
Productivity tips for developers
PDF
Linux Shell (Expiry of Domain and Certificate)
PDF
Subversion To Mercurial
DOCX
computer project code ''payroll'' (based on datafile handling)
Spatial script for MongoBoulder
Spatial script for my JS.Everywhere 2012
Script for Spatial Mongo
Productivity tips for developers
Linux Shell (Expiry of Domain and Certificate)
Subversion To Mercurial
computer project code ''payroll'' (based on datafile handling)

What's hot (20)

PPT
Python And GIS - Beyond Modelbuilder And Pythonwin
PDF
Javascript Continues Integration in Jenkins with AngularJS
KEY
サイ本 文
PPTX
CouchDB Day NYC 2017: MapReduce Views
DOC
Quiz using C++
PPTX
2015 555 kharchenko_ppt
PDF
Tests unitaires pour PostgreSQL avec pgTap
PDF
Log file analysis by Peter Nikolow
PPTX
CouchDB Day NYC 2017: Full Text Search
PPTX
CouchDB Day NYC 2017: Introduction to CouchDB 2.0
PPTX
CouchDB Day NYC 2017: JSON Documents
PDF
PHP 机智问答
PPTX
Commit2015 kharchenko - python generators - ext
PDF
Essential git fu for tech writers
PDF
Gitosis on Mac OS X Server
PDF
HPCC Systems - ECL for Programmers - Big Data - Data Scientist
PPTX
Visualizing ORACLE performance data with R @ #C16LV
DOCX
PDF
php[world] 2016 - You Don’t Need Node.js - Async Programming in PHP
PDF
Openstack at NTT Feb 7, 2011
Python And GIS - Beyond Modelbuilder And Pythonwin
Javascript Continues Integration in Jenkins with AngularJS
サイ本 文
CouchDB Day NYC 2017: MapReduce Views
Quiz using C++
2015 555 kharchenko_ppt
Tests unitaires pour PostgreSQL avec pgTap
Log file analysis by Peter Nikolow
CouchDB Day NYC 2017: Full Text Search
CouchDB Day NYC 2017: Introduction to CouchDB 2.0
CouchDB Day NYC 2017: JSON Documents
PHP 机智问答
Commit2015 kharchenko - python generators - ext
Essential git fu for tech writers
Gitosis on Mac OS X Server
HPCC Systems - ECL for Programmers - Big Data - Data Scientist
Visualizing ORACLE performance data with R @ #C16LV
php[world] 2016 - You Don’t Need Node.js - Async Programming in PHP
Openstack at NTT Feb 7, 2011
Ad

Viewers also liked (9)

PDF
Spatial script for CIMA
PPT
Workshop For pycon13
PDF
London Cloud Summit 2014 - raising the tide: getting developers in the cloud
PPTX
Spatial mongo for PHP and Zend
PPTX
APPLICATIONS AND CONTAINERS AT SCALE: OpenShift + Kubernetes + Docker
PPTX
Spatial MongoDB, Node.JS, and Express - server-side JS for your application
PDF
Introduction to PaaS for application developers
PPTX
Monkigras - dropping science on your developer ecosystem
ODP
Build a PaaS with OpenShift Origin
Spatial script for CIMA
Workshop For pycon13
London Cloud Summit 2014 - raising the tide: getting developers in the cloud
Spatial mongo for PHP and Zend
APPLICATIONS AND CONTAINERS AT SCALE: OpenShift + Kubernetes + Docker
Spatial MongoDB, Node.JS, and Express - server-side JS for your application
Introduction to PaaS for application developers
Monkigras - dropping science on your developer ecosystem
Build a PaaS with OpenShift Origin
Ad

Similar to Spatial script for Spatial mongo for PHP and Zend (20)

PDF
MongoSF - Spatial MongoDB in OpenShift - script file
PDF
Script for the geomeetup presentation
PDF
Chapman: Building a High-Performance Distributed Task Service with MongoDB
PPT
9b. Document-Oriented Databases lab
TXT
Books
KEY
Building Your First MongoDB Application
KEY
Building your first application w/mongoDB MongoSV2011
PPTX
Webinar: Index Tuning and Evaluation
PDF
Apache Hadoop Shell Rewrite
PPTX
QA Fes 2016. Ярослав Пернеровский. Не Jav'ой единой. Пример автоматизации тес...
PDF
MongoDB全機能解説2
PPT
Introduction to MongoDB
PDF
Latinoware
PPTX
Conceptos básicos. Seminario web 4: Indexación avanzada, índices de texto y g...
PDF
San Francisco Java User Group
PPTX
2012 coscup - Build your PHP application on Heroku
PDF
Building Your First MongoDB Application
PDF
はじめてのMongoDB
PPT
Nosh slides mongodb web application - mongo philly 2011
PDF
Automated Spark Deployment With Declarative Infrastructure
MongoSF - Spatial MongoDB in OpenShift - script file
Script for the geomeetup presentation
Chapman: Building a High-Performance Distributed Task Service with MongoDB
9b. Document-Oriented Databases lab
Books
Building Your First MongoDB Application
Building your first application w/mongoDB MongoSV2011
Webinar: Index Tuning and Evaluation
Apache Hadoop Shell Rewrite
QA Fes 2016. Ярослав Пернеровский. Не Jav'ой единой. Пример автоматизации тес...
MongoDB全機能解説2
Introduction to MongoDB
Latinoware
Conceptos básicos. Seminario web 4: Indexación avanzada, índices de texto y g...
San Francisco Java User Group
2012 coscup - Build your PHP application on Heroku
Building Your First MongoDB Application
はじめてのMongoDB
Nosh slides mongodb web application - mongo philly 2011
Automated Spark Deployment With Declarative Infrastructure

More from Steven Pousty (11)

PPTX
Spatial Mongo and Node.JS on Openshift JS.Everywhere 2012
PPTX
Dropping Science on Your Developer Ecosystem - lessons from Ecosystem Management
PDF
Open shift intro for Philly PUG
PPT
Open shift intro for Philly PUG
PPT
Openshift GeoSpatial Capabilities
PPT
Mongo sf spatialmongo
PPTX
OpenShift with Eclipse Tooling - EclipseCon 2012
PPTX
Free Mongo on OpenShift
PPTX
deCarta at BAPI
PPT
LinuxFest NW - Using Postgis To Add Some Spatial Flavor To Your App
PPT
Using PostGIS To Add Some Spatial Flavor To Your Application
Spatial Mongo and Node.JS on Openshift JS.Everywhere 2012
Dropping Science on Your Developer Ecosystem - lessons from Ecosystem Management
Open shift intro for Philly PUG
Open shift intro for Philly PUG
Openshift GeoSpatial Capabilities
Mongo sf spatialmongo
OpenShift with Eclipse Tooling - EclipseCon 2012
Free Mongo on OpenShift
deCarta at BAPI
LinuxFest NW - Using Postgis To Add Some Spatial Flavor To Your App
Using PostGIS To Add Some Spatial Flavor To Your Application

Spatial script for Spatial mongo for PHP and Zend

  • 1. 1 #commands for adding spatial data! 2 ! 3 #Take a look at the file first! 4 #less parkcoord.json! 5 ! 6 #get the file on the server! 7 scp parkcoord.json 30bb1262b1364026855e358a649f171b@parks-spmongo.rhcloud.com:app-root/data! 8 ! 9 #ssh into the machine! 10 ssh 30bb1262b1364026855e358a649f171b@parks-spmongo.rhcloud.com! 11 ! 12 ! 13 #import into mongo! 14 mongoimport -d parks -c parkpoints --type json --file app-root/data/parkcoord.json -h … $OPENSHIFT_NOSQL_DB_HOST -u admin -p $OPENSHIFT_NOSQL_DB_PASSWORD! 15 ! 16 #open the mongo shell! 17 mongo ! 18 ! 19 #build the index! 20 db.parkpoints.ensureIndex({"pos":"2d"});! 21 ! 22 #Now some queries! 23 #simple spatial! 24 db.parkpoints.find({"pos" : { "$near" : [-37, 41]}});! 25 ! 26 #spatial and text query using regex! 27 db.parkpoints.find( { Name : /lincoln/i, pos : { $near : [-37,41] }} );! 28 ! 29 #geonear TODO! 30 db.runCommand({ geoNear : "parkpoints", near : [-37,41], num : 10 });! 31 ! 32 ! 33 #create a new collection from scratch! 34 db.createCollection("checkin");! 35 db.checkin.ensureIndex( { "pos" : "2d" } );! 36 ! 37 #insert a new record! 38 db.checkin.insert({ "created" : new Date(), "Notes" : 'just landed', "pos" : [-76.7302 , 25.5332 ] })! 39 ! ! 40 #quick query to make sure it worked! 41 db.checkin.find( { pos : { $near : [-37,41] } } )! 42 ! 43 #add a second document closer to query point! 44 #this is an upsert - since we don't pass in the _id it creates a new record! 45 db.checkin.save({ created : new Date(), Notes: 'that was a big step', pos : [-37.7302 , 40.5332 ]});! 46 ! 47 #one way to update original document! 48 myDoc = db.checkin.findOne({_id : ObjectId("50130d8ea8f6532e83026bc1")});! 49 myDoc.Notes = "really the landing";! 50 db.checkin.save(myDoc);! 51 ! 52