lbs with mongodb

12
LBS WITH MONGODB LOCATION BASED SERVICE WITH MONGODB ( 몽고디비로 위치기반 서비스 만들기 ) 2011년 6월 14일 화요일

Upload: yonghyuk-lee

Post on 25-May-2015

377 views

Category:

Documents


0 download

DESCRIPTION

LBS( Location Based Service) with MongoDB

TRANSCRIPT

Page 1: LBS with MongoDB

LBS WITH MONGODBLOCATION BASED SERVICE WITH MONGODB

( 몽고디비로 위치기반 서비스 만들기 )

2011년 6월 14일 화요일

Page 2: LBS with MongoDB

강사소개

이용혁

ITEMBAY / 신사업팀

PROGRAMMER / 팀장

SPRINGSPROUT / UNLOGICAL

OKJSP / SKYNLE

TWITTER / SKYNLE

2011년 6월 14일 화요일

Page 3: LBS with MongoDB

DAUM PLACE, FOURSQUARE, GOOGLE PLACES

2011년 6월 14일 화요일

Page 4: LBS with MongoDB

SAMPLE PAGEHTTP://192.168.123.1:8080/MONGO/MAP

300,000

150,000/1분

1 SELECT & 1 UPDATE

MACBOOK PRO, DUAL CORE 2.54G, 4G, 128SSD

JBOSS 5.1 WITH IN ECLIPSE / JDK 1.6

MONGODB 1.8

2011년 6월 14일 화요일

Page 5: LBS with MongoDB

OTHERS ?

SPRING3

SPRING DATA MONGO ...

GOOGLE MAP V3

TILES2

JQUERY

ALL FREE

2011년 6월 14일 화요일

Page 6: LBS with MongoDB

WHY MONGODB ?

FREE

GEOSPATIAL INDEX

DISTANCE

EASY WITH JAVA

AND ...

2011년 6월 14일 화요일

Page 7: LBS with MongoDB

MONGODBHTTP://MONGODB.ORG

2011년 6월 14일 화요일

Page 8: LBS with MongoDB

MONGODB GEOSPATIAL INDEX

>db.places.insert({ loc : [ 50 , 30 ] })>db.places.insert({ loc : { x : 50 , y : 30 } })>db.places.insert({ loc : { foo : 50 , y : 30 } })>db.places.insert({ loc : { long : 40.7390,lat: 73.9929 } })

>db.places.ensureIndex( { loc : "2d" } )

>db.places.find( { loc : [50,50] } )

>db.places.find( { loc : { $near : [50,50] } } )

>db.places.find( { loc : { $near : [50,50] } } ).limit(20)

>db.places.find( { loc : { $near : [50,50] , $maxDistance : 5 } } ).limit(20)

2011년 6월 14일 화요일

Page 9: LBS with MongoDB

MONGODB GEOSPATIAL INDEX

>db.places.ensureIndex( { location : "2d" , category : 1 } );>db.places.find( { location : { $near : [50,50] }, category : 'coffee' });

Compound Indexes

geoNear Command> db.runCommand( { geoNear : "places" , near : [50,50], num : 10 } , query : { category : 'coffee' });

Valid options are: "near", "num", "maxDistance", "distanceMultiplier" and "query"

2011년 6월 14일 화요일

Page 10: LBS with MongoDB

MONGODB GEOSPATIAL INDEX

public List<DBObject> retriveByLoc(int flag, Double geolong, Double geolat) { DBObject cmd = new BasicDBObject(), query = new BasicDBObject();; query = new BasicDBObject(); query.put("flag", flag); Object[] location = new Object[]{ geolong, geolat }; cmd = new BasicDBObject(); cmd.put("geoNear", "position"); cmd.put("near", location); cmd.put("num", 30); cmd.put("distanceMultiplier", 1.609344*1000*1000); //거리의 단위 m cmd.put("spherical", true); //거리계산 ? cmd.put("query", query);

CommandResult cr = mongoTemplate.getDb().command(cmd); return (List<DBObject>)cr.get("results"); }

2011년 6월 14일 화요일

Page 11: LBS with MongoDB

WHAT ?

MONGODB를 이용하여편리하고, 가볍게

위치기반서비스(LBS)를 제작할 수 있다.

2011년 6월 14일 화요일

Page 12: LBS with MongoDB

Q/A

2011년 6월 14일 화요일