rgeo 3.0.0.pre.rc.1 → 3.0.0.pre.rc.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +11 -11
  3. data/ext/geos_c_impl/factory.c +31 -30
  4. data/ext/geos_c_impl/factory.h +8 -1
  5. data/ext/geos_c_impl/geometry.c +70 -0
  6. data/ext/geos_c_impl/geometry_collection.c +43 -40
  7. data/ext/geos_c_impl/line_string.c +2 -2
  8. data/ext/geos_c_impl/main.c +1 -1
  9. data/ext/geos_c_impl/polygon.c +29 -22
  10. data/ext/geos_c_impl/preface.h +4 -0
  11. data/ext/geos_c_impl/ruby_more.c +65 -0
  12. data/ext/geos_c_impl/ruby_more.h +16 -0
  13. data/lib/rgeo/cartesian/factory.rb +6 -7
  14. data/lib/rgeo/cartesian/feature_classes.rb +2 -0
  15. data/lib/rgeo/cartesian/feature_methods.rb +16 -0
  16. data/lib/rgeo/cartesian/interface.rb +0 -30
  17. data/lib/rgeo/coord_sys.rb +0 -11
  18. data/lib/rgeo/feature/factory_generator.rb +0 -3
  19. data/lib/rgeo/feature/geometry.rb +79 -0
  20. data/lib/rgeo/geographic/factory.rb +6 -0
  21. data/lib/rgeo/geographic/interface.rb +1 -29
  22. data/lib/rgeo/geographic/projected_feature_methods.rb +16 -0
  23. data/lib/rgeo/geographic/spherical_feature_methods.rb +17 -1
  24. data/lib/rgeo/geos/capi_factory.rb +0 -7
  25. data/lib/rgeo/geos/capi_feature_classes.rb +19 -0
  26. data/lib/rgeo/geos/ffi_factory.rb +6 -7
  27. data/lib/rgeo/geos/ffi_feature_methods.rb +16 -0
  28. data/lib/rgeo/geos/interface.rb +0 -17
  29. data/lib/rgeo/geos/zm_factory.rb +0 -7
  30. data/lib/rgeo/geos/zm_feature_methods.rb +16 -0
  31. data/lib/rgeo/geos.rb +6 -3
  32. data/lib/rgeo/impl_helper/validity_check.rb +3 -2
  33. data/lib/rgeo/version.rb +1 -1
  34. metadata +18 -5
  35. data/lib/rgeo/coord_sys/srs_database/entry.rb +0 -107
  36. data/lib/rgeo/coord_sys/srs_database/sr_org.rb +0 -64
  37. data/lib/rgeo/coord_sys/srs_database/url_reader.rb +0 -65
@@ -1,107 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # -----------------------------------------------------------------------------
4
- #
5
- # SRS database interface
6
- #
7
- # -----------------------------------------------------------------------------
8
-
9
- module RGeo
10
- module CoordSys
11
- # This module contains tools for accessing spatial reference
12
- # databases. These are databases (either local or remote) from which
13
- # you can look up coordinate system specifications, typically in
14
- # either OGC or Proj4 format. For example, you can access the
15
- # <tt>spatial_ref_sys</tt> table provided with an OGC-compliant RDBMS
16
- # such as PostGIS. You can also read the database files provided with
17
- # the proj4 library, or access online databases such as the
18
- # spatialreference.org site.
19
-
20
- # Spatial reference system database classes must implement these methods:
21
- # get
22
- # clear_cache
23
- #
24
- # See SrOrg and UrlReader for implementations of SRSDatabase classes.
25
- #
26
- # Retrieve an Entry given an identifier. The identifier is usually
27
- # a numeric spatial reference ID (SRID), but could be a string
28
- # value for certain database types.
29
- # get(identifier)
30
- #
31
- # Clear any cache utilized by this database.
32
- # clear_cache
33
-
34
- module SRSDatabase
35
- # An entry in a spatial reference system database.
36
- # Every entry has an identifier, but all the other attributes are
37
- # optional and may or may not be present depending on the database.
38
- class Entry
39
- # Create an entry.
40
- # You must provide an identifier, which may be numeric or a
41
- # string. The data hash should contain any other attributes,
42
- # keyed by symbol.
43
- #
44
- # Some attribute inputs have special behaviors:
45
- #
46
- # [<tt>:coord_sys</tt>]
47
- # You can pass a CS coordinate system object, or a string in
48
- # WKT format.
49
- # [<tt>:proj4</tt>]
50
- # You can pass a Proj4 object, or a proj4-format string.
51
- # [<tt>:name</tt>]
52
- # If the name is not provided directly, it is taken from the
53
- # coord_sys.
54
- # [<tt>:authority</tt>]
55
- # If the authority name is not provided directly, it is taken
56
- # from the coord_sys.
57
- # [<tt>:authority_code</tt>]
58
- # If the authority code is not provided directly, it is taken
59
- # from the coord_sys.
60
-
61
- def initialize(ident, data = {})
62
- @identifier = ident
63
- @authority = data[:authority]
64
- @authority_code = data[:authority_code]
65
- @name = data[:name]
66
- @description = data[:description]
67
- @coord_sys = data[:coord_sys]
68
- if @coord_sys.is_a?(String)
69
- @coord_sys = CS.create_from_wkt(@coord_sys)
70
- end
71
- @proj4 = data[:proj4]
72
- if @proj4 && CoordSys.check!(:proj4)
73
- if @proj4.is_a?(String) || @proj4.is_a?(Hash)
74
- @proj4 = Proj4.create(@proj4)
75
- end
76
- end
77
- if @coord_sys
78
- @name = @coord_sys.name unless @name
79
- @authority = @coord_sys.authority unless @authority
80
- @authority_code = @coord_sys.authority unless @authority_code
81
- end
82
- end
83
-
84
- # The database key or identifier.
85
- attr_reader :identifier
86
-
87
- # The authority name, if present. Example: "epsg".
88
- attr_reader :authority
89
-
90
- # The authority code, e.g. an EPSG code.
91
- attr_reader :authority_code
92
-
93
- # A human-readable name for this coordinate system.
94
- attr_reader :name
95
-
96
- # A human-readable description for this coordinate system.
97
- attr_reader :description
98
-
99
- # The CS::CoordinateSystem object.
100
- attr_reader :coord_sys
101
-
102
- # The Proj4 object.
103
- attr_reader :proj4
104
- end
105
- end
106
- end
107
- end
@@ -1,64 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # -----------------------------------------------------------------------------
4
- #
5
- # SRS database interface
6
- #
7
- # -----------------------------------------------------------------------------
8
-
9
- require "net/http"
10
-
11
- module RGeo
12
- module CoordSys
13
- module SRSDatabase
14
- # A spatial reference database implementation that fetches data
15
- # from the spatialreference.org website.
16
-
17
- class SrOrg
18
- # Create a database backed by the given catalog of the
19
- # spatialreference.org website. Catalogs currently supported by
20
- # spatialreference.org are "epsg", "esri", "iau2000" and "sr-org".
21
- #
22
- # Options:
23
- #
24
- # [<tt>:cache</tt>]
25
- # If set to true, lookup results are cached so if the same URL
26
- # is requested again, the result is served from cache rather
27
- # than issuing another HTTP request. Default is false.
28
-
29
- def initialize(catalog, opts = {})
30
- @catalog = catalog.to_s.downcase
31
- @cache = opts[:cache] ? {} : nil
32
- end
33
-
34
- # The spatialreference.org catalog used by this database.
35
- attr_reader :catalog
36
-
37
- # Retrieve the Entry from a spatialreference.org catalog given an
38
- # integer ID.
39
-
40
- def get(ident)
41
- ident = ident.to_s
42
- return @cache[ident] if @cache&.include?(ident)
43
- coord_sys = nil
44
- proj4 = nil
45
- Net::HTTP.start("spatialreference.org") do |http|
46
- response = http.request_get("/ref/#{@catalog}/#{ident}/ogcwkt/")
47
- coord_sys = response.body if response.is_a?(Net::HTTPSuccess)
48
- response = http.request_get("/ref/#{@catalog}/#{ident}/proj4/")
49
- proj4 = response.body if response.is_a?(Net::HTTPSuccess)
50
- end
51
- result = Entry.new(ident, coord_sys: coord_sys.strip, proj4: proj4.strip)
52
- @cache[ident] = result if @cache
53
- result
54
- end
55
-
56
- # Clear the cache if one exists.
57
-
58
- def clear_cache
59
- @cache&.clear
60
- end
61
- end
62
- end
63
- end
64
- end
@@ -1,65 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # -----------------------------------------------------------------------------
4
- #
5
- # SRS database interface
6
- #
7
- # -----------------------------------------------------------------------------
8
-
9
- require "net/http"
10
-
11
- module RGeo
12
- module CoordSys
13
- module SRSDatabase
14
- # A spatial reference database implementation that fetches data from
15
- # internet URLs.
16
-
17
- class UrlReader
18
- # Create a URL-based spatial reference database.
19
- #
20
- # Options:
21
- #
22
- # [<tt>:cache</tt>]
23
- # If set to true, lookup results are cached so if the same URL
24
- # is requested again, the result is served from cache rather
25
- # than issuing another HTTP request. Default is false.
26
-
27
- def initialize(opts = {})
28
- @cache = opts[:cache] ? {} : nil
29
- end
30
-
31
- # Retrieve the given URL and return an Entry.
32
- # Returns nil if the URL cannot be read as an OGC WKT or Proj4
33
- # coordinate system
34
-
35
- def get(ident)
36
- ident = ident.to_s
37
- return @cache[ident] if @cache&.include?(ident)
38
- uri = URI.parse(ident)
39
- result = nil
40
- Net::HTTP.start(uri.host, uri.port) do |http|
41
- request = uri.path
42
- request = "#{request}?#{uri.query}" if uri.query
43
- response = http.requestget(request)
44
- if response.is_a?(Net::HTTPSuccess)
45
- response = response.body.strip
46
- if response[0, 1] == "+"
47
- result = Entry.new(ident, proj4: response)
48
- else
49
- result = Entry.new(ident, coord_sys: response)
50
- end
51
- end
52
- end
53
- @cache[ident] = result if @cache
54
- result
55
- end
56
-
57
- # Clear the cache if one is present.
58
-
59
- def clear_cache
60
- @cache&.clear
61
- end
62
- end
63
- end
64
- end
65
- end