SlideShare ist ein Scribd-Unternehmen logo
1 von 12
Downloaden Sie, um offline zu lesen
LBS WITH MONGODB
                      LOCATION BASED SERVICE WITH MONGODB
                          ( 몽고디비로 위치기반 서비스 만들기 )

2011년	 6월	 14일	 화요일
강사소개

                이용혁

                ITEMBAY / 신사업팀

                PROGRAMMER / 팀장

                SPRINGSPROUT / UNLOGICAL

                OKJSP / SKYNLE

                TWITTER / SKYNLE




2011년	 6월	 14일	 화요일
DAUM PLACE, FOURSQUARE, GOOGLE PLACES


2011년	 6월	 14일	 화요일
SAMPLE PAGE
               HTTP://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일	 화요일
OTHERS ?

                SPRING3

                SPRING DATA MONGO ...

                GOOGLE MAP V3

                TILES2

                JQUERY

                ALL FREE




2011년	 6월	 14일	 화요일
WHY MONGODB ?

                FREE

                GEOSPATIAL INDEX

                DISTANCE

                EASY WITH JAVA

                AND ...




2011년	 6월	 14일	 화요일
MONGODB
                      HTTP://MONGODB.ORG




2011년	 6월	 14일	 화요일
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일	 화요일
MONGODB GEOSPATIAL INDEX
          Compound Indexes
          >db.places.ensureIndex(
               { location : "2d" , category : 1 }
            );
          >db.places.find(
            {
               location : { $near : [50,50] },
               category : 'coffee'
            });


          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일	 화요일
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일	 화요일
WHAT ?

                      MONGODB를 이용하여
                        편리하고, 가볍게
                      위치기반서비스(LBS)를
                        제작할 수 있다.




2011년	 6월	 14일	 화요일
Q/A




2011년	 6월	 14일	 화요일

Weitere ähnliche Inhalte

Andere mochten auch

وثيقة سرية للإخوان المسلمين حول
وثيقة سرية للإخوان المسلمين حولوثيقة سرية للإخوان المسلمين حول
وثيقة سرية للإخوان المسلمين حولIbrahimia Church Ftriends
 
Spring 2012 Plumbing Catalog
Spring 2012 Plumbing CatalogSpring 2012 Plumbing Catalog
Spring 2012 Plumbing CatalogCCEC_US
 
47. الوصية الخامسة سلسله عظات الوصايا العشر القس كرم لامعى صباح الأح...
47. الوصية الخامسة     سلسله عظات الوصايا العشر   القس كرم لامعى    صباح الأح...47. الوصية الخامسة     سلسله عظات الوصايا العشر   القس كرم لامعى    صباح الأح...
47. الوصية الخامسة سلسله عظات الوصايا العشر القس كرم لامعى صباح الأح...Ibrahimia Church Ftriends
 
انشودة الرجاء فى ليل الشقاء منبر الكنيسه الإنجيليه بالإبراهيميه- ا...
انشودة     الرجاء     فى ليل الشقاء    منبر الكنيسه الإنجيليه بالإبراهيميه- ا...انشودة     الرجاء     فى ليل الشقاء    منبر الكنيسه الإنجيليه بالإبراهيميه- ا...
انشودة الرجاء فى ليل الشقاء منبر الكنيسه الإنجيليه بالإبراهيميه- ا...Ibrahimia Church Ftriends
 

Andere mochten auch (6)

وثيقة سرية للإخوان المسلمين حول
وثيقة سرية للإخوان المسلمين حولوثيقة سرية للإخوان المسلمين حول
وثيقة سرية للإخوان المسلمين حول
 
Madkour and elroby
Madkour and elrobyMadkour and elroby
Madkour and elroby
 
Spring 2012 Plumbing Catalog
Spring 2012 Plumbing CatalogSpring 2012 Plumbing Catalog
Spring 2012 Plumbing Catalog
 
Scopus author feedback
Scopus author feedbackScopus author feedback
Scopus author feedback
 
47. الوصية الخامسة سلسله عظات الوصايا العشر القس كرم لامعى صباح الأح...
47. الوصية الخامسة     سلسله عظات الوصايا العشر   القس كرم لامعى    صباح الأح...47. الوصية الخامسة     سلسله عظات الوصايا العشر   القس كرم لامعى    صباح الأح...
47. الوصية الخامسة سلسله عظات الوصايا العشر القس كرم لامعى صباح الأح...
 
انشودة الرجاء فى ليل الشقاء منبر الكنيسه الإنجيليه بالإبراهيميه- ا...
انشودة     الرجاء     فى ليل الشقاء    منبر الكنيسه الإنجيليه بالإبراهيميه- ا...انشودة     الرجاء     فى ليل الشقاء    منبر الكنيسه الإنجيليه بالإبراهيميه- ا...
انشودة الرجاء فى ليل الشقاء منبر الكنيسه الإنجيليه بالإبراهيميه- ا...
 

Mehr von YongHyuk Lee

Vert.X and MSA - DevOps
Vert.X and MSA - DevOpsVert.X and MSA - DevOps
Vert.X and MSA - DevOpsYongHyuk Lee
 
Microservices chat
Microservices chatMicroservices chat
Microservices chatYongHyuk Lee
 
2015 JBUG KOREA MEETUP - spring4 width infinispan
2015 JBUG KOREA MEETUP - spring4 width infinispan2015 JBUG KOREA MEETUP - spring4 width infinispan
2015 JBUG KOREA MEETUP - spring4 width infinispanYongHyuk Lee
 
spring3.2 java config Servler3
spring3.2 java config Servler3spring3.2 java config Servler3
spring3.2 java config Servler3YongHyuk Lee
 

Mehr von YongHyuk Lee (6)

Vert.X and MSA - DevOps
Vert.X and MSA - DevOpsVert.X and MSA - DevOps
Vert.X and MSA - DevOps
 
Microservices chat
Microservices chatMicroservices chat
Microservices chat
 
2015 JBUG KOREA MEETUP - spring4 width infinispan
2015 JBUG KOREA MEETUP - spring4 width infinispan2015 JBUG KOREA MEETUP - spring4 width infinispan
2015 JBUG KOREA MEETUP - spring4 width infinispan
 
spring3.2 java config Servler3
spring3.2 java config Servler3spring3.2 java config Servler3
spring3.2 java config Servler3
 
Infinispan
InfinispanInfinispan
Infinispan
 
OAuth2.0
OAuth2.0OAuth2.0
OAuth2.0
 

LBS with MongoDB

  • 1. LBS WITH MONGODB LOCATION BASED SERVICE WITH MONGODB ( 몽고디비로 위치기반 서비스 만들기 ) 2011년 6월 14일 화요일
  • 2. 강사소개 이용혁 ITEMBAY / 신사업팀 PROGRAMMER / 팀장 SPRINGSPROUT / UNLOGICAL OKJSP / SKYNLE TWITTER / SKYNLE 2011년 6월 14일 화요일
  • 3. DAUM PLACE, FOURSQUARE, GOOGLE PLACES 2011년 6월 14일 화요일
  • 4. SAMPLE PAGE HTTP://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일 화요일
  • 5. OTHERS ? SPRING3 SPRING DATA MONGO ... GOOGLE MAP V3 TILES2 JQUERY ALL FREE 2011년 6월 14일 화요일
  • 6. WHY MONGODB ? FREE GEOSPATIAL INDEX DISTANCE EASY WITH JAVA AND ... 2011년 6월 14일 화요일
  • 7. MONGODB HTTP://MONGODB.ORG 2011년 6월 14일 화요일
  • 8. 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일 화요일
  • 9. MONGODB GEOSPATIAL INDEX Compound Indexes >db.places.ensureIndex( { location : "2d" , category : 1 } ); >db.places.find( { location : { $near : [50,50] }, category : 'coffee' }); 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일 화요일
  • 10. 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일 화요일
  • 11. WHAT ? MONGODB를 이용하여 편리하고, 가볍게 위치기반서비스(LBS)를 제작할 수 있다. 2011년 6월 14일 화요일