geekdaily-georuby 2.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (90) hide show
  1. checksums.yaml +7 -0
  2. data/.github/ISSUE_TEMPLATE/bug_report.md +38 -0
  3. data/.github/ISSUE_TEMPLATE/code-of-conduct-issue.md +10 -0
  4. data/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
  5. data/.gitignore +7 -0
  6. data/.rubocop.yml +8 -0
  7. data/.travis.yml +24 -0
  8. data/CODE_OF_CONDUCT.md +132 -0
  9. data/CONTRIBUTING.md +19 -0
  10. data/Gemfile +4 -0
  11. data/Guardfile +16 -0
  12. data/History.txt +4 -0
  13. data/MIT-LICENSE +7 -0
  14. data/README.md +237 -0
  15. data/Rakefile +32 -0
  16. data/bench.rb +35 -0
  17. data/georuby.gemspec +38 -0
  18. data/lib/geo_ruby.rb +11 -0
  19. data/lib/geo_ruby/ewk.rb +2 -0
  20. data/lib/geo_ruby/ewk/ewkb_parser.rb +206 -0
  21. data/lib/geo_ruby/ewk/ewkt_parser.rb +321 -0
  22. data/lib/geo_ruby/geojson.rb +139 -0
  23. data/lib/geo_ruby/georss.rb +156 -0
  24. data/lib/geo_ruby/gpx.rb +113 -0
  25. data/lib/geo_ruby/kml.rb +96 -0
  26. data/lib/geo_ruby/shp.rb +2 -0
  27. data/lib/geo_ruby/shp4r/dbf.rb +60 -0
  28. data/lib/geo_ruby/shp4r/shp.rb +726 -0
  29. data/lib/geo_ruby/simple_features.rb +21 -0
  30. data/lib/geo_ruby/simple_features/circle.rb +59 -0
  31. data/lib/geo_ruby/simple_features/envelope.rb +174 -0
  32. data/lib/geo_ruby/simple_features/geometry.rb +252 -0
  33. data/lib/geo_ruby/simple_features/geometry_collection.rb +143 -0
  34. data/lib/geo_ruby/simple_features/geometry_factory.rb +84 -0
  35. data/lib/geo_ruby/simple_features/helper.rb +18 -0
  36. data/lib/geo_ruby/simple_features/line_string.rb +224 -0
  37. data/lib/geo_ruby/simple_features/linear_ring.rb +34 -0
  38. data/lib/geo_ruby/simple_features/multi_line_string.rb +56 -0
  39. data/lib/geo_ruby/simple_features/multi_point.rb +52 -0
  40. data/lib/geo_ruby/simple_features/multi_polygon.rb +55 -0
  41. data/lib/geo_ruby/simple_features/point.rb +463 -0
  42. data/lib/geo_ruby/simple_features/polygon.rb +172 -0
  43. data/lib/geo_ruby/version.rb +3 -0
  44. data/lib/georuby.rb +2 -0
  45. data/spec/data/geojson/feature.json +9 -0
  46. data/spec/data/geojson/feature_collection.json +33 -0
  47. data/spec/data/georss/atom.xml +21 -0
  48. data/spec/data/georss/gml.xml +40 -0
  49. data/spec/data/georss/w3c.xml +22 -0
  50. data/spec/data/gpx/fells_loop.gpx +1077 -0
  51. data/spec/data/gpx/long.gpx +1642 -0
  52. data/spec/data/gpx/long.kml +31590 -0
  53. data/spec/data/gpx/long.nmea +2220 -0
  54. data/spec/data/gpx/short.gpx +13634 -0
  55. data/spec/data/gpx/short.kml +130 -0
  56. data/spec/data/gpx/tracktreks.gpx +706 -0
  57. data/spec/data/multipoint.dbf +0 -0
  58. data/spec/data/multipoint.shp +0 -0
  59. data/spec/data/multipoint.shx +0 -0
  60. data/spec/data/point.dbf +0 -0
  61. data/spec/data/point.shp +0 -0
  62. data/spec/data/point.shx +0 -0
  63. data/spec/data/polygon.dbf +0 -0
  64. data/spec/data/polygon.shp +0 -0
  65. data/spec/data/polygon.shx +0 -0
  66. data/spec/data/polyline.dbf +0 -0
  67. data/spec/data/polyline.shp +0 -0
  68. data/spec/data/polyline.shx +0 -0
  69. data/spec/geo_ruby/ewk/ewkb_parser_spec.rb +157 -0
  70. data/spec/geo_ruby/ewk/ewkt_parser_spec.rb +178 -0
  71. data/spec/geo_ruby/geojson_spec.rb +164 -0
  72. data/spec/geo_ruby/georss_spec.rb +238 -0
  73. data/spec/geo_ruby/gpx_spec.rb +103 -0
  74. data/spec/geo_ruby/kml_spec.rb +102 -0
  75. data/spec/geo_ruby/shp4r/shp_spec.rb +246 -0
  76. data/spec/geo_ruby/simple_features/circle_spec.rb +14 -0
  77. data/spec/geo_ruby/simple_features/envelope_spec.rb +47 -0
  78. data/spec/geo_ruby/simple_features/geometry_collection_spec.rb +55 -0
  79. data/spec/geo_ruby/simple_features/geometry_factory_spec.rb +11 -0
  80. data/spec/geo_ruby/simple_features/geometry_spec.rb +37 -0
  81. data/spec/geo_ruby/simple_features/line_string_spec.rb +268 -0
  82. data/spec/geo_ruby/simple_features/linear_ring_spec.rb +24 -0
  83. data/spec/geo_ruby/simple_features/multi_line_string_spec.rb +54 -0
  84. data/spec/geo_ruby/simple_features/multi_point_spec.rb +35 -0
  85. data/spec/geo_ruby/simple_features/multi_polygon_spec.rb +50 -0
  86. data/spec/geo_ruby/simple_features/point_spec.rb +547 -0
  87. data/spec/geo_ruby/simple_features/polygon_spec.rb +121 -0
  88. data/spec/geo_ruby_spec.rb +22 -0
  89. data/spec/spec_helper.rb +73 -0
  90. metadata +322 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 742592d481aced08b036a20f97ee82489ee5a292a8beb683d59149c035b53a6d
4
+ data.tar.gz: 931dae623d8b34ac99b776e081730b228a3db1c7f9e6773972f5272d9b1c8102
5
+ SHA512:
6
+ metadata.gz: 69542cbbf371fa52f6580067637e70a1cf4daf21cda2224758b793eb3abc77bb1b392eff11ef8892c761e3377a3406eddf20643978146ce1a421ba262bf2348d
7
+ data.tar.gz: 7d2099883a3159ed1a922df28916bab91457af83b89f624eaf8cb0dfae9d1fe9342b72f45aadfe80be2bad6684e057ff7fb86e7e762cd9a8b3af1e3c8eda0c1e
@@ -0,0 +1,38 @@
1
+ ---
2
+ name: Bug report
3
+ about: Create a report to help us improve
4
+ title: ''
5
+ labels: bug
6
+ assignees: ''
7
+
8
+ ---
9
+
10
+ **Describe the bug**
11
+ A clear and concise description of what the bug is.
12
+
13
+ **To Reproduce**
14
+ Steps to reproduce the behavior:
15
+ 1. Go to '...'
16
+ 2. Click on '....'
17
+ 3. Scroll down to '....'
18
+ 4. See error
19
+
20
+ **Expected behavior**
21
+ A clear and concise description of what you expected to happen.
22
+
23
+ **Screenshots**
24
+ If applicable, add screenshots to help explain your problem.
25
+
26
+ **Desktop (please complete the following information):**
27
+ - OS: [e.g. iOS]
28
+ - Browser [e.g. chrome, safari]
29
+ - Version [e.g. 22]
30
+
31
+ **Smartphone (please complete the following information):**
32
+ - Device: [e.g. iPhone6]
33
+ - OS: [e.g. iOS8.1]
34
+ - Browser [e.g. stock browser, safari]
35
+ - Version [e.g. 22]
36
+
37
+ **Additional context**
38
+ Add any other context about the problem here.
@@ -0,0 +1,10 @@
1
+ ---
2
+ name: Code of conduct issue
3
+ about: Report a code of conduct issue
4
+ title: "[COC] "
5
+ labels: code of conduct
6
+ assignees: purp
7
+
8
+ ---
9
+
10
+
@@ -0,0 +1,20 @@
1
+ ---
2
+ name: Feature request
3
+ about: Suggest an idea for this project
4
+ title: ''
5
+ labels: enhancement
6
+ assignees: ''
7
+
8
+ ---
9
+
10
+ **Is your feature request related to a problem? Please describe.**
11
+ A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12
+
13
+ **Describe the solution you'd like**
14
+ A clear and concise description of what you want to happen.
15
+
16
+ **Describe alternatives you've considered**
17
+ A clear and concise description of any alternative solutions or features you've considered.
18
+
19
+ **Additional context**
20
+ Add any other context or screenshots about the feature request here.
data/.gitignore ADDED
@@ -0,0 +1,7 @@
1
+ .DS_Store
2
+ pkg/*.gem
3
+ pkg/*.tgz
4
+ pkg/**/*
5
+ coverage/*
6
+ doc/*
7
+ Gemfile.lock
data/.rubocop.yml ADDED
@@ -0,0 +1,8 @@
1
+ #
2
+ # Rubocop's dirty cop
3
+ #
4
+ Style/AsciiComments:
5
+ Enabled: false
6
+
7
+ Metrics/LineLength:
8
+ Max: 89
data/.travis.yml ADDED
@@ -0,0 +1,24 @@
1
+ version: ~> 1.0
2
+ language: ruby
3
+ rvm:
4
+ - 2.6.6
5
+ - 2.7.2
6
+ - 3.0.0
7
+ - ruby-head
8
+ - jruby
9
+ - jruby-head
10
+ env:
11
+ global:
12
+ - CC_TEST_REPORTER_ID=0969386fb2d2c792937fa61d8d832f5cd903c1a3d46788fcf19617808c72682a
13
+ - CI=true
14
+ before_script:
15
+ - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
16
+ - chmod +x ./cc-test-reporter
17
+ - ./cc-test-reporter before-build
18
+ script: bundle exec rake spec
19
+ after_script:
20
+ - ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
21
+ matrix:
22
+ allow_failures:
23
+ - rvm: ruby-head
24
+ - rvm: jruby-head
@@ -0,0 +1,132 @@
1
+
2
+ # Contributor Covenant Code of Conduct
3
+
4
+ ## Our Pledge
5
+
6
+ We as members, contributors, and leaders pledge to make participation in our
7
+ community a harassment-free experience for everyone, regardless of age, body
8
+ size, visible or invisible disability, ethnicity, sex characteristics, gender
9
+ identity and expression, level of experience, education, socio-economic status,
10
+ nationality, personal appearance, race, religion, or sexual identity
11
+ and orientation.
12
+
13
+ We pledge to act and interact in ways that contribute to an open, welcoming,
14
+ diverse, inclusive, and healthy community.
15
+
16
+ ## Our Standards
17
+
18
+ Examples of behavior that contributes to a positive environment for our
19
+ community include:
20
+
21
+ * Demonstrating empathy and kindness toward other people
22
+ * Being respectful of differing opinions, viewpoints, and experiences
23
+ * Giving and gracefully accepting constructive feedback
24
+ * Accepting responsibility and apologizing to those affected by our mistakes,
25
+ and learning from the experience
26
+ * Focusing on what is best not just for us as individuals, but for the
27
+ overall community
28
+
29
+ Examples of unacceptable behavior include:
30
+
31
+ * The use of sexualized language or imagery, and sexual attention or
32
+ advances of any kind
33
+ * Trolling, insulting or derogatory comments, and personal or political attacks
34
+ * Public or private harassment
35
+ * Publishing others' private information, such as a physical or email
36
+ address, without their explicit permission
37
+ * Other conduct which could reasonably be considered inappropriate in a
38
+ professional setting
39
+
40
+ ## Enforcement Responsibilities
41
+
42
+ Community leaders are responsible for clarifying and enforcing our standards of
43
+ acceptable behavior and will take appropriate and fair corrective action in
44
+ response to any behavior that they deem inappropriate, threatening, offensive,
45
+ or harmful.
46
+
47
+ Community leaders have the right and responsibility to remove, edit, or reject
48
+ comments, commits, code, wiki edits, issues, and other contributions that are
49
+ not aligned to this Code of Conduct, and will communicate reasons for moderation
50
+ decisions when appropriate.
51
+
52
+ ## Scope
53
+
54
+ This Code of Conduct applies within all community spaces, and also applies when
55
+ an individual is officially representing the community in public spaces.
56
+ Examples of representing our community include using an official e-mail address,
57
+ posting via an official social media account, or acting as an appointed
58
+ representative at an online or offline event.
59
+
60
+ ## Enforcement
61
+
62
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
63
+ reported to the community leaders responsible for enforcement by [filing a new issue in this GitHub repository](https://github.com/geekdaily/georuby/issues/new/choose).
64
+ All complaints will be reviewed and investigated promptly and fairly.
65
+
66
+ All community leaders are obligated to respect the privacy and security of the
67
+ reporter of any incident.
68
+
69
+ ## Enforcement Guidelines
70
+
71
+ Community leaders will follow these Community Impact Guidelines in determining
72
+ the consequences for any action they deem in violation of this Code of Conduct:
73
+
74
+ ### 1. Correction
75
+
76
+ **Community Impact**: Use of inappropriate language or other behavior deemed
77
+ unprofessional or unwelcome in the community.
78
+
79
+ **Consequence**: A private, written warning from community leaders, providing
80
+ clarity around the nature of the violation and an explanation of why the
81
+ behavior was inappropriate. A public apology may be requested.
82
+
83
+ ### 2. Warning
84
+
85
+ **Community Impact**: A violation through a single incident or series
86
+ of actions.
87
+
88
+ **Consequence**: A warning with consequences for continued behavior. No
89
+ interaction with the people involved, including unsolicited interaction with
90
+ those enforcing the Code of Conduct, for a specified period of time. This
91
+ includes avoiding interactions in community spaces as well as external channels
92
+ like social media. Violating these terms may lead to a temporary or
93
+ permanent ban.
94
+
95
+ ### 3. Temporary Ban
96
+
97
+ **Community Impact**: A serious violation of community standards, including
98
+ sustained inappropriate behavior.
99
+
100
+ **Consequence**: A temporary ban from any sort of interaction or public
101
+ communication with the community for a specified period of time. No public or
102
+ private interaction with the people involved, including unsolicited interaction
103
+ with those enforcing the Code of Conduct, is allowed during this period.
104
+ Violating these terms may lead to a permanent ban.
105
+
106
+ ### 4. Permanent Ban
107
+
108
+ **Community Impact**: Demonstrating a pattern of violation of community
109
+ standards, including sustained inappropriate behavior, harassment of an
110
+ individual, or aggression toward or disparagement of classes of individuals.
111
+
112
+ **Consequence**: A permanent ban from any sort of public interaction within
113
+ the community.
114
+
115
+ ## Attribution
116
+
117
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
118
+ version 2.0, available at
119
+ [https://www.contributor-covenant.org/version/2/0/code_of_conduct.html][v2.0].
120
+
121
+ Community Impact Guidelines were inspired by
122
+ [Mozilla's code of conduct enforcement ladder][Mozilla CoC].
123
+
124
+ For answers to common questions about this code of conduct, see the FAQ at
125
+ [https://www.contributor-covenant.org/faq][FAQ]. Translations are available
126
+ at [https://www.contributor-covenant.org/translations][translations].
127
+
128
+ [homepage]: https://www.contributor-covenant.org
129
+ [v2.0]: https://www.contributor-covenant.org/version/2/0/code_of_conduct.html
130
+ [Mozilla CoC]: https://github.com/mozilla/diversity
131
+ [FAQ]: https://www.contributor-covenant.org/faq
132
+ [translations]: https://www.contributor-covenant.org/translations
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,19 @@
1
+ ## How To Contribute
2
+
3
+ 1. Fork this repo
4
+ 2. Make a branch with a descriptive name, e.g. `fix_stupid_geo_data_bug` or `docs_cleanup`
5
+ 3. Make changes there
6
+ 4. File a pull request when you're ready
7
+ 5. Enjoy wealth, fame, and my everlasting gratitude. _Warning: I can only deliver one of these personally; the rest come over time with effort._
8
+
9
+ ## Setting up your dev environment
10
+
11
+ ### Things That Help Make Sense Of All This
12
+
13
+ EWKB — (Extremely?) Well Known Binary text representations of geo data, see https://en.wikipedia.org/wiki/Well-known_text_representation_of_geometry
14
+
15
+ x,y,z,m — m is a milestone or benchmark used as an origin for this measurement, see https://en.wikipedia.org/wiki/Linear_referencing
16
+
17
+ SRID specifies the spatial coordinate system you're using, see https://en.wikipedia.org/wiki/Spatial_reference_system
18
+
19
+ The classic degrees-minutes-seconds representation is called sexagesimal degree, see https://en.wikipedia.org/wiki/Geographic_coordinate_conversion
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify gem dependencies in georuby.gemspec
4
+ gemspec
data/Guardfile ADDED
@@ -0,0 +1,16 @@
1
+ #
2
+ # GeoRuby Guardfile
3
+ #
4
+ ignore(/\/.#.+/)
5
+
6
+ # notification :off
7
+
8
+ guard :rubocop, all_on_start: false, keep_failed: false, notification: false, cli: ['--format', 'emacs', '-D'] do
9
+ watch(/^lib\/(.+)\.rb$/)
10
+ end
11
+
12
+ guard :rspec, cmd: 'bundle exec rspec', notification: true, title: 'GeoRuby' do
13
+ watch(/^spec\/.+_spec\.rb$/)
14
+ watch(/^lib\/(.+)\.rb$/) { |m| "spec/#{m[1]}_spec.rb" }
15
+ watch('spec/spec_helper.rb') { 'spec' }
16
+ end
data/History.txt ADDED
@@ -0,0 +1,4 @@
1
+ == 0.0.1 2008-08-14
2
+
3
+ * 1 major enhancement:
4
+ * Initial release
data/MIT-LICENSE ADDED
@@ -0,0 +1,7 @@
1
+ Copyright (c) 2006 Guilhem Vellut <guilhem.vellut+georuby@gmail.com>
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,237 @@
1
+ GeoRuby
2
+ =======
3
+
4
+
5
+ A Brief Warning re: `geekdaily/georuby`
6
+ ---------------------------------------
7
+ I've used this a little, but not heavily, and decided I'd add some bits that seemed generally useful and convenient to me, as well as clean up and make some of it a bit more accessible as I learn more about the code and geometric data. I'm aiming to be sure not to break things, but if you want rock-solid-stable-implemented-by-someone-who-knew-what-they-were-doing, I recommend sticking with [NoFxx's version](https://github.com/nofxx/georuby).
8
+
9
+ Overview
10
+ --------
11
+
12
+ This is intended as a holder for geometric data.
13
+ The data model roughly follows the OGC "Simple Features for SQL" specification,
14
+ so it should play nice with data returned from PostGIS or any Spatial Extensions (MongoDB, MySQL...).
15
+ It also supports various output and input formats (GeoRSS, KML, Shapefile).
16
+ GeoRuby is written in pure Ruby.
17
+
18
+ OGC:"http://www.opengis.org/docs/99-049.pdf"
19
+
20
+ If you are looking for Proj/Geos (geometric operators or reprojections) rubygem checkout: (C extension)
21
+ rgeo:"https://github.com/dazuma/rgeo"
22
+
23
+ [![Build Status](https://travis-ci.org/geekdaily/georuby.svg?branch=master)](https://travis-ci.org/geekdaily/georuby)
24
+ [![Maintainability](https://api.codeclimate.com/v1/badges/f9107afad07fa0ffab18/maintainability)](https://codeclimate.com/github/geekdaily/georuby/maintainability)
25
+ [![Test Coverage](https://api.codeclimate.com/v1/badges/f9107afad07fa0ffab18/test_coverage)](https://codeclimate.com/github/geekdaily/georuby/test_coverage)
26
+
27
+ Available data types
28
+ --------------------
29
+
30
+ The following geometric data types are provided :
31
+ - Point
32
+ - Line String
33
+ - Linear Ring
34
+ - Polygon
35
+ - Multi Point
36
+ - Multi Line String
37
+ - Multi Polygon
38
+ - Geometry Collection
39
+
40
+ They can be in 2D, 3DZ, 3DM, and 4D.
41
+
42
+ On top of this an Envelope class is available, to contain the bounding box of a geometry.
43
+
44
+
45
+ Installation
46
+ ------------
47
+
48
+ To install the latest version, just type:
49
+
50
+ gem install georuby
51
+
52
+ Or include on your projects`s Gemfile:
53
+
54
+ gem 'georuby'
55
+
56
+
57
+ Optional, require if you need the functionality:
58
+
59
+
60
+ require 'georuby'
61
+ require 'geo_ruby/ewk' # EWKT/EWKB
62
+ require 'geo_ruby/shp' # Shapefile
63
+ require 'geo_ruby/gpx' # GPX data
64
+ require 'geo_ruby/kml' # KML data
65
+ require 'geo_ruby/georss' # GeoRSS
66
+ require 'geo_ruby/geojson' # GeoJSON
67
+
68
+ TODO: https://github.com/AnalyticalGraphicsInc/czml-writer
69
+
70
+ Use
71
+ ===
72
+
73
+ Simple Examples
74
+ ----------------
75
+
76
+ Creating a 3D Point:
77
+
78
+ include GeoRuby::SimpleFeatures
79
+ Point.from_x_y_z(10.0, 20.0, 5.0)
80
+
81
+
82
+ Creating a LineString:
83
+
84
+ LineString.from_coordinates([[1,1],[2,2]],4326)
85
+
86
+
87
+ Creating a Polygon:
88
+
89
+ coordinates = [[0,0],[0,1],[1,1],[1,0]]
90
+ outer_ring = LinearRing.from_coordinates(coordinates, 4326)
91
+ rings = [outer_ring]
92
+ Polygon.from_linear_rings(rings)
93
+
94
+ Checking if a Point is inside a Polygon:
95
+
96
+ point = Point.from_x_y(0.5, 0.5)
97
+ polygon = Polygon.from_coordinates([[[0,0],[0,1],[1,1],[1,0]]],4326)
98
+ polygon.contains_point?(point)
99
+
100
+ Input and output
101
+ ----------------
102
+
103
+ These geometries can be input and output in WKB/EWKB/WKT/EWKT format as well as
104
+ the related HexWKB and HexEWKB formats. HexEWKB and WKB are the default form under
105
+ which geometric data is returned respectively from PostGIS and MySql.
106
+
107
+ GeoRSS Simple, GeoRSS W3CGeo, GeoRSS GML can also be input and output.
108
+ Note that they will not output valid RSS, but just the part strictly concerning
109
+ the geometry as outlined in http://www.georss.org/1/ . Since the model does
110
+ not allow multiple geometries, for geometry collections, only the first geometry
111
+ will be output. Similarly, for polygons, the GeoRSS output will only contain the outer ring.
112
+ As for W3CGeo output, only points can be output, so the first point of the geometry is chosen.
113
+ By default the Simple format is output. Envelope can also be output in these formats:
114
+ The box geometric type is chosen (except for W3CGeo, where the center of the envelope is chose).
115
+ These formats can also be input and a GeoRuby geometry will be created.
116
+ Note that it will not read a valid RSS file, only a geometry string.
117
+
118
+ On top of that, there is now support for KML output and input.
119
+ As for GeoRSS, a valid KML file will not be output, but only the geometric data.
120
+ Options <tt>:id</tt>, <tt>:extrude</tt>, <tt>:tesselate</tt> and <tt>:altitude_mode</tt> can be given.
121
+ Note that if the <tt>:altitude_mode</tt> option is not passed or set to <tt>clampToGround</tt>,
122
+ the altitude data will not be output even if present. Envelopes output a LatLonAltBox instead of a geometry.
123
+ For the output, the following geometric types are supported : Point, LineString, Polygon.
124
+
125
+
126
+ SHP reading and writing
127
+ ---
128
+
129
+ Georuby has support for reading ESRI shapefiles (http://www.esri.com/library/whitepapers/pdfs/shapefile.pdf).
130
+ A tool called <tt>shp2sql.rb</tt> is also provided: it shows how to use the SHP reading functionality together
131
+ with the spatial adapter plugin for Rails to import spatial features into MySQL and PostGIS.
132
+
133
+ Here is an example of Shapefile reading, that goes through all the geometries
134
+ in a file and disaply the values of the attributes :
135
+
136
+ require 'geo_ruby/shp'
137
+
138
+ GeoRuby::Shp4r::ShpFile.open(shpfile) do |shp|
139
+ shp.each do |shape|
140
+ geom = shape.geometry #a GeoRuby SimpleFeature
141
+ att_data = shape.data #a Hash
142
+ shp.fields.each do |field|
143
+ puts att_data[field.name]
144
+ end
145
+ end
146
+ end
147
+
148
+ Support for ESRI shapefile creation and modification has been added as well.
149
+ New shapefiles can be created given a geometry type and specifications for the DBF fields.
150
+ Data can be added and removed from an existing shapefile.
151
+ An update operation is also provided for convenience: it just performs a 'delete' and an 'add',
152
+ which means the index of the modified record will change. Note that once a shapefile has been created,
153
+ GeoRuby does not allow the modification of the schema (it will probably be done in a subsequent version).
154
+
155
+ Here is an example of how to create a new Shapefile with 2 fields :
156
+
157
+ shpfile = GeoRuby::Shp4r::ShpFile.create('hello.shp', ShpType::POINT, [DBF::Field.new("Hoyoyo", "C", 10), DBF::Field.new("Boyoul","N",10,0)])
158
+
159
+ The file is then open for reading and writing.
160
+
161
+ Here is an example of how to write to a shapefile (created or not with GeoRuby) :
162
+
163
+ shpfile = GeoRuby::Shp4r::ShpFile.open('places.shp')
164
+ shpfile.transaction do |tr|
165
+ tr.add(ShpRecord.new(Point.from_x_y(123.4, 123.4), 'Hoyoyo' => "AEZ",'Bouyoul' => 45))
166
+ tr.update(4, ShpRecord.new(Point.from_x_y(-16.67, 16.41), 'Hoyoyo' => "EatMe",'Bouyoul' => 42))
167
+ tr.delete(1)
168
+ end
169
+ shpfile.close
170
+
171
+ Note the transaction is just there so the operations on the files can be buffered.
172
+ Nothing happens on the original files until the block has finished executing.
173
+ Calling <tt>tr.rollback</tt> at anytime during the execution will prevent the modifications.
174
+
175
+ Also currently, error reporting is minimal and it has not been tested that
176
+ thoroughly so caveat emptor and backup before performing any destructive operation.
177
+
178
+ Shapefile names and extensions (dbf, shp, gpx) must be lowercased!
179
+
180
+
181
+ GPX Reading
182
+ -----------
183
+
184
+ You can read and convert GPX Files to LineString/Polygon:
185
+
186
+ gpxfile = GpxFile.open('tour.gpx')
187
+ gpxfile.as_line_string
188
+ => GeoRuby::SimpleFeatures::LineString..
189
+
190
+
191
+ GeoJSON Support
192
+ ---------------
193
+
194
+ Basic GeoJSON support has been implemented per v1.0 of the {spec}[http://geojson.org/geojson-spec.html].
195
+
196
+ USAGE:
197
+
198
+ input - `GeoRuby::SimpleFeatures::Geometry.from_geojson(geojson_string)`
199
+ output - call `#as_geojson` or `#to_json` on any SimpleFeature Geometry instance
200
+
201
+ TODO:
202
+
203
+ * Refactor to support extremely large GeoJSON input streams / files. Currently
204
+ the entire GeoJSON representation must be loaded into memory as a String
205
+ * Improve srid/crs support on input and add support on output
206
+ * Implement bounding-box spport per spec on input/output?
207
+ * Improved / more tests
208
+
209
+ GeoJSON support implemented by {Marcus Mateus}[http://github.com/marcusmateus] and released courtesy {SimpliTex}[http://simplitex.com].
210
+
211
+
212
+ ### Extra Features
213
+
214
+ - Writing of ESRI shapefiles
215
+ - Reading of ESRI shapefiles
216
+ - Tool to import spatial features in MySQL and PostGIS from a SHP file
217
+
218
+
219
+ ### Acknowledgement
220
+
221
+ The SHP reading part uses the DBF library (http://rubyforge.org/projects/dbf/) by Keith Morrison (http://infused.org).
222
+ Thanks also to Pramukta Kumar and Pete Schwamb for their contributions.
223
+
224
+
225
+ ## Support (Original GeoRuby gem)
226
+
227
+ Any questions, enhancement proposals, bug notifications or corrections
228
+ can be sent to guilhem.vellut@gmail.com.
229
+
230
+
231
+ ### Coming in the next versions
232
+
233
+ - Schema modification of existing shapefiles
234
+ - More error reporting when writing shapefiles
235
+ - More tests on writing shapefiles ; tests on real-world shapefiles
236
+ - Better shp2sql import tool
237
+ - Documentation