SlideShare una empresa de Scribd logo
1 de 52
Geo                 Ruby
  (           Rails)
      @tetsutan (    )
about:me

• @tetsutan
•
• 83          82
http://gihyo.jp/news/report/01/rubykaigi2011/0001
Today’s Recipe

• RGeo
• Rails/ActiveRecordSpatialAdapter
• Rails/GeoHash
• Rails/Mongoid
RGeo
• http://virtuoso.rubyforge.org/rgeo/
• gem install rgeo
• RGeo is a geospatial data library for Ruby.
• “At its core is an implementation of the
  industry standard OGC Simple Features
  Specification,”
OpenGIS

• http://www.opengeospatial.org/
• The Open Geospatial Consortium, Inc.
• GIS
 •   GIS   Geographic Information System
GeoRuby

• http://georuby.rubyforge.org/
• “The data model roughly follows the OGC
  Simple Features for SQL specification”
• “The library inputs and outputs EWKB,
  HexEWKB and EWKT.”
EWKT, EWKB,
         HexEWKB
• EWKT/EWKB
 • Extended Well-Known Text/Binary
   •   Point(35.739406 139.653755)

   •   x000000000101000000AC3B16DBA4DE414016139B8FEB746140


• HexEWKB
 • EWKB with Hex
   •   “000000000101000000AC3B16DBA4DE414016139B8FEB746140”
Create WKB w MySQL
MySQL/PostgreSQL
•
• PostgreSQL                  PostGIS
  MySQL                            GIS



• MySQL           Doc
 •   http://dev.mysql.com/doc/refman/5.1/ja/spatial-extensions.html
• RGeo
 ‣ Ruby   GIS


• MySQL
 ‣ WKT/WKB
Today’s Recipe

• RGeo
• Rails/ActiveRecordSpatialAdapter
• Rails/GeoHash
• Rails/Mongoid
Spatial Adapter
• gem search --remote spatial
 • spatial_adapter (1.2.0)
 • activerecord-spatialite-adapter (0.3.3)
 • activerecord-mysqlspatial-adapter (0.3.2)
 • activerecord-mysql2spatial-adapter (0.3.2)
• postgres
 • activerecord-postgis-adapter (0.3.5)
Spatial Adapter
• gem search --remote spatial
 • spatial_adapter (1.2.0)
 • activerecord-spatialite-adapter (0.3.3)
 • activerecord-mysqlspatial-adapter (0.3.2)
 • activerecord-mysql2spatial-adapter (0.3.2)
• postgres
 • activerecord-postgis-adapter (0.3.5)
spatial_adapter

•
• GeoRuby
•
Spatial Adapter
• gem search --remote spatial
 • spatial_adapter (1.2.0)
 • activerecord-spatialite-adapter (0.3.3)
 • activerecord-mysqlspatial-adapter (0.3.2)
 • activerecord-mysql2spatial-adapter (0.3.2)
• postgres
 • activerecord-postgis-adapter (0.3.5)
MySQL
Gemfile


gem "activerecord-mysql2spatial-adapter"
Migrate

create_table :locations do |t|
 t.string :name, :null => false, :limit => 255
 t.point :geom, :null => false
 t.timestamps
end
Controller

factory = RGeo::Cartesian.factory
@location.geom = factory.point(3,4)
“130.0, 30.0”


                   Point(130.0 30.0)
                  RGeo




                              SpatialAdapter
INSERT INTO LOC (geom) values( Point(130.0 30.0) );



                                               MySQL
SpatialAdapter
SpatialAdapter
•   ActiveRecord


•   Mysql


•   OGC


    •
    •              Point


    •   z
Today’s Recipe

• RGeo
• Rails/ActiveRecordSpatialAdapter
• Rails/GeoHash
• Rails/Mongoid
GeoHash


• http://geohash.org/
• “It is a hierarchical spatial data structure which
  subdivides space into buckets of grid shape”
(@masuidrive)
  http://blog.masuidrive.jp/index.php/2010/01/13/geohash/
GeoHash
• AABBCCDDEE ∈ AABBCCDD
• also AABBCCDDFF ∈ AABBCCDD
               AABBCCDDEE
                        AABBCCDDFF


                            AABBCCDD
• ”GAE   DataStore
                                Geohash


             ”

                 http://blog.masuidrive.jp/index.php/2010/01/13/geohash/
GeoHash


•   String   OK
Today’s Recipe

• RGeo
• Rails/ActiveRecordSpatialAdapter
• Rails/GeoHash
• Rails/Mongoid
Mongodb
•
•       indexing

•
•
• etc
Geospatial Indexing!!
Geospatial Indexing
• mongoDB 1.3.3 or later
•
         { loc : [ 50 , 30 ] }
         { loc : { x : 50 , y : 30 } }
         { loc : { foo : 50 , y : 30 } }
         { loc : { long : 40.739037, lat: 73.992964 } }



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


• MongoMapper
• Mongoid
Mongoid
• http://mongoid.org/
• MongoMapper
•          id:babie

        “        Rails3
             Mongoid
             ”            http://d.hatena.ne.jp/babie/20100809/1281316971
• Document
• Spatial Index
• devise
• Spatial Index
  -   Mongoid

  -   MM


• devise
  -   Mongoid

  -   MM
Model
Controller
Conclusion
• 4sq
              GeoHash MongoDB

•
    MongoDB

• Mongoid/MongoMapper
        Mongoid
activerecord-
mysql2spatial-adapter
      (0.3.2)
activerecord-mysql2spatial-
          adapter (0.3.2)


fixture geometry
17




     https://gist.github.com/1093641
•   RGeo
    •  http://virtuoso.rubyforge.org/rgeo/
•   OpenGIS
    •  http://www.opengeospatial.org
•   GeoHash
    •  http://geohash.org/
    •  masuidrive       http://blog.masuidrive.jp/index.php/2010/01/13/geohash/

•   Mongoid
    •  http://mongoid.org
    •  babie     http://d.hatena.ne.jp/babie/20100809/1281316971

•   my gist
    •   https://gist.github.com/1093641

Más contenido relacionado

Similar a rubykaigi2011_spatial.key

Geospatial Rails applications
Geospatial Rails applicationsGeospatial Rails applications
Geospatial Rails applicationsOlga Lavrentieva
 
PostgreSQL 9.4: NoSQL on ACID
PostgreSQL 9.4: NoSQL on ACIDPostgreSQL 9.4: NoSQL on ACID
PostgreSQL 9.4: NoSQL on ACIDOleg Bartunov
 
Application devevelopment with open source libraries
Application devevelopment with open source librariesApplication devevelopment with open source libraries
Application devevelopment with open source librariesAllan Laframboise
 
GeoPackage, Context and POI (and a sprinkle of GeoJSON)
GeoPackage, Context and POI (and a sprinkle of GeoJSON)GeoPackage, Context and POI (and a sprinkle of GeoJSON)
GeoPackage, Context and POI (and a sprinkle of GeoJSON) Raj Singh
 
超カジュアルに使うMySQL @ MySQL Casual Talks #2
超カジュアルに使うMySQL @ MySQL Casual Talks #2超カジュアルに使うMySQL @ MySQL Casual Talks #2
超カジュアルに使うMySQL @ MySQL Casual Talks #2Tasuku Suenaga
 
Getting Started with Geospatial Data in MongoDB
Getting Started with Geospatial Data in MongoDBGetting Started with Geospatial Data in MongoDB
Getting Started with Geospatial Data in MongoDBMongoDB
 
Saving Money with Open Source GIS
Saving Money with Open Source GISSaving Money with Open Source GIS
Saving Money with Open Source GISbryanluman
 
Using Spring with NoSQL databases (SpringOne China 2012)
Using Spring with NoSQL databases (SpringOne China 2012)Using Spring with NoSQL databases (SpringOne China 2012)
Using Spring with NoSQL databases (SpringOne China 2012)Chris Richardson
 
Integrating PostGIS in Web Applications
Integrating PostGIS in Web ApplicationsIntegrating PostGIS in Web Applications
Integrating PostGIS in Web ApplicationsCommand Prompt., Inc
 
Polyglot Persistence & Big Data in the Cloud
Polyglot Persistence & Big Data in the CloudPolyglot Persistence & Big Data in the Cloud
Polyglot Persistence & Big Data in the CloudAndrei Savu
 
Sinatraで触れる生SQL
Sinatraで触れる生SQLSinatraで触れる生SQL
Sinatraで触れる生SQLtreby
 
视觉中国的MongoDB应用实践(QConBeijing2011)
视觉中国的MongoDB应用实践(QConBeijing2011)视觉中国的MongoDB应用实践(QConBeijing2011)
视觉中国的MongoDB应用实践(QConBeijing2011)Night Sailer
 
LocationTech Projects
LocationTech ProjectsLocationTech Projects
LocationTech ProjectsJody Garnett
 
High Performance Weibo QCon Beijing 2011
High Performance Weibo QCon Beijing 2011High Performance Weibo QCon Beijing 2011
High Performance Weibo QCon Beijing 2011Tim Y
 
Geoindexing with MongoDB
Geoindexing with MongoDBGeoindexing with MongoDB
Geoindexing with MongoDBleafnode
 
2011/10/08_Playframework_GAE_to_Heroku
2011/10/08_Playframework_GAE_to_Heroku2011/10/08_Playframework_GAE_to_Heroku
2011/10/08_Playframework_GAE_to_HerokuTakeshi Hagikura
 
Node js quick-tour_v2
Node js quick-tour_v2Node js quick-tour_v2
Node js quick-tour_v2http403
 
Node js quick tour v2
Node js quick tour v2Node js quick tour v2
Node js quick tour v2Wyatt Fang
 
Node js quick-tour_v2
Node js quick-tour_v2Node js quick-tour_v2
Node js quick-tour_v2tianyi5212222
 

Similar a rubykaigi2011_spatial.key (20)

Impression of Rails 3
Impression of Rails 3Impression of Rails 3
Impression of Rails 3
 
Geospatial Rails applications
Geospatial Rails applicationsGeospatial Rails applications
Geospatial Rails applications
 
PostgreSQL 9.4: NoSQL on ACID
PostgreSQL 9.4: NoSQL on ACIDPostgreSQL 9.4: NoSQL on ACID
PostgreSQL 9.4: NoSQL on ACID
 
Application devevelopment with open source libraries
Application devevelopment with open source librariesApplication devevelopment with open source libraries
Application devevelopment with open source libraries
 
GeoPackage, Context and POI (and a sprinkle of GeoJSON)
GeoPackage, Context and POI (and a sprinkle of GeoJSON)GeoPackage, Context and POI (and a sprinkle of GeoJSON)
GeoPackage, Context and POI (and a sprinkle of GeoJSON)
 
超カジュアルに使うMySQL @ MySQL Casual Talks #2
超カジュアルに使うMySQL @ MySQL Casual Talks #2超カジュアルに使うMySQL @ MySQL Casual Talks #2
超カジュアルに使うMySQL @ MySQL Casual Talks #2
 
Getting Started with Geospatial Data in MongoDB
Getting Started with Geospatial Data in MongoDBGetting Started with Geospatial Data in MongoDB
Getting Started with Geospatial Data in MongoDB
 
Saving Money with Open Source GIS
Saving Money with Open Source GISSaving Money with Open Source GIS
Saving Money with Open Source GIS
 
Using Spring with NoSQL databases (SpringOne China 2012)
Using Spring with NoSQL databases (SpringOne China 2012)Using Spring with NoSQL databases (SpringOne China 2012)
Using Spring with NoSQL databases (SpringOne China 2012)
 
Integrating PostGIS in Web Applications
Integrating PostGIS in Web ApplicationsIntegrating PostGIS in Web Applications
Integrating PostGIS in Web Applications
 
Polyglot Persistence & Big Data in the Cloud
Polyglot Persistence & Big Data in the CloudPolyglot Persistence & Big Data in the Cloud
Polyglot Persistence & Big Data in the Cloud
 
Sinatraで触れる生SQL
Sinatraで触れる生SQLSinatraで触れる生SQL
Sinatraで触れる生SQL
 
视觉中国的MongoDB应用实践(QConBeijing2011)
视觉中国的MongoDB应用实践(QConBeijing2011)视觉中国的MongoDB应用实践(QConBeijing2011)
视觉中国的MongoDB应用实践(QConBeijing2011)
 
LocationTech Projects
LocationTech ProjectsLocationTech Projects
LocationTech Projects
 
High Performance Weibo QCon Beijing 2011
High Performance Weibo QCon Beijing 2011High Performance Weibo QCon Beijing 2011
High Performance Weibo QCon Beijing 2011
 
Geoindexing with MongoDB
Geoindexing with MongoDBGeoindexing with MongoDB
Geoindexing with MongoDB
 
2011/10/08_Playframework_GAE_to_Heroku
2011/10/08_Playframework_GAE_to_Heroku2011/10/08_Playframework_GAE_to_Heroku
2011/10/08_Playframework_GAE_to_Heroku
 
Node js quick-tour_v2
Node js quick-tour_v2Node js quick-tour_v2
Node js quick-tour_v2
 
Node js quick tour v2
Node js quick tour v2Node js quick tour v2
Node js quick tour v2
 
Node js quick-tour_v2
Node js quick-tour_v2Node js quick-tour_v2
Node js quick-tour_v2
 

Último

DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demoHarshalMandlekar2
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
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
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
What is Artificial Intelligence?????????
What is Artificial Intelligence?????????What is Artificial Intelligence?????????
What is Artificial Intelligence?????????blackmambaettijean
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 

Último (20)

DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demo
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
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
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
What is Artificial Intelligence?????????
What is Artificial Intelligence?????????What is Artificial Intelligence?????????
What is Artificial Intelligence?????????
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 

rubykaigi2011_spatial.key

Notas del editor

  1. Rubyで位置情報のデータを扱う場合に着いて話をします\n
  2. 前職はKoozytという会社でARのプラットフォーム開発やってましたが、もともと位置情報好きでKoozytへ入社しました。\n4月末に会社をやめてから3ヶ月ほどニートしています。\n自分でも位置情報系のサービスを作っているんですが、\n位置情報系のサービスを位置情報関連の美味しいお仕事あればご連絡ください\nプレゼンソフトもってなかったので昨日keynote買いました\nなので文字ばっかのプレゼンなので眠いと思います\n\n\n
  3. とか闇の方から聞こえてきた気がきがしますが気ににしません\n
  4. 今日のプレゼンではこのあたりの話をします\n今作っているサービスのバックエンドの変遷\nでもあります。\n先に結論を話すと、この順番に試して結局Mongoにたどり着きました。\n練習したら20分とかかかったので、頭3つは少し飛ばし気味に話していきます\n
  5. coreはOGCで標準化されたsimple features の仕様に基づいて実装されている\n
  6. KMLとかもここで決めてます\n
  7. RGeoの一世代前のライブラリはこれです。\nこいつはまたあとで顔を出してきます。使わないですが\n
  8. ちなみにこのlat/lonは練馬文化センターの位置情報です\nWKTはPoint(x y)の間がスペースなので気をつけてください。\n
  9. ポスグレは知りませんが似たようなことはできると思います。\nMySQLの話がでたのでつぎはMysqlについて\n
  10. さっき見てもらったとおり\n\nたぶんsqliteでもデータ突っ込むだけなら単純に配列なのでOK(indexがはれないとかあるかも。重要なのはspatial index)\n
  11. となるとORマッパーが欲しいですね\n
  12. \n
  13. Spatial ってのは空間っていう意味です\n
  14. \n
  15. \n
  16. 新しいのはこいつら。\n名前でわかると思いますが、\nsqlite, mysql, mysql2, postgresql\nのアダプタです。\n
  17. \n
  18. \n
  19. このへんはspatialadapterのおかげです\n
  20. GeorubyのときはPoint.newとかできたんですが、RGeoになってからファクトリーをつくらなくてはならなくなりました\n
  21. \n
  22. \n
  23. 一応出来るんですが、複雑な計算式をSQLでかかないといけない\n
  24. OGC準拠ってのは利点があってDB側でいろんな操作が可能\n
  25. \n
  26. 階層構造で、グリッドに分割される\n
  27. \n
  28. \n
  29. ということなのでGAEを使うか、自前で前方一致が早い検索エンジンを使うとかしないとSQLでLike文使うとかになっちゃいます。Solrとかならできると思います\n\nGeoHashのruby用ライブラリも増井さんが作成してくれています\n
  30. なので、頭から2文字づつとか保存しれやればインデックスも効くし、ひとつの方法としてはありかなと思っています。\n
  31. やっと本題です\n
  32. \n
  33. まずはMongodbについて、このあたりはさらっと流します\n詳しくはdoryokujinさんのブログで\n\nほんといいことずくめのDBです。KVSとは違うって行ってるんですが、まあ考え方は一緒です。\n
  34. \n
  35. \n
  36. \n
  37. 最近のmongodbだったら問題ないです\n\n1.3.3 Releasedってのが2010/3/2にメールが流れているのでここ1年くらいに導入したなら対応しています\n\nこのあたりはMysqlがspatial indexのサポートをしているのと同じ\n\nこの例の場合、placesテーブルにlocカラムがあって、それが2D Index => Geospatial Indexとなる\n
  38. 僕はMongoidを使いました\n
  39. \n
  40. \n
  41. deviseはメールアドレスなどでログインするフォームなどを簡単に作成してくれるライブラリ。\n位置情報とは関係ないですが、このプラグインがあるのを前提に他を作ってしまってました。\nこれも詳しくはbabieさんのブログ参照\n
  42. \n
  43. \n
  44. 最終的に\n\nこのindexのつけ方もドキュメントにあります。\n
  45. こんな感じでfinderとか使えます。\narelと同じ感じでメソッドチェーンできます。\n特にnearの部分が位置情報には大事\ngeomには0にlat、1にlonが入ってます\n
  46. \n
  47. \n
  48. 残念ながら使わなくなったんですが、こいつのパッチを書きました\n何が問題かというと\n
  49. これ、多分、だれもコレ使ってテストしてないってことだと思うんですが、どうなんでしょうかね?\n
  50. しかも完全じゃない\nwktだけの対応です。\nでもコレ見つけるのかなり苦労しました。\nActiveRecordの中とか読みました\n
  51. \n
  52. \n