Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add delegation to geometry in Feature (#53)
Feature is now provided a `method_missing` that will default to inner geometry. FeatureCollection has access to some OGC methods, and a method_missing message to indicate the lack of implementation if one uses a not yet implemented method.
- Loading branch information
Showing
10 changed files
with
212 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
--- !ruby/object:RDoc::Options | ||
encoding: UTF-8 | ||
static_path: [] | ||
rdoc_include: | ||
- "." | ||
- "/Users/ulysse/Dev/rgeo/rgeo-geojson" | ||
charset: UTF-8 | ||
exclude: !ruby/regexp /~\z|\.orig\z|\.rej\z|\.bak\z|\.gemspec\z/ | ||
hyperlink_all: false | ||
line_numbers: false | ||
locale: | ||
locale_dir: locale | ||
locale_name: | ||
main_page: | ||
markup: markdown | ||
output_decoration: true | ||
page_dir: | ||
show_hash: false | ||
tab_width: 8 | ||
template_stylesheets: [] | ||
title: | ||
visibility: :protected | ||
webcvs: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
# frozen_string_literal: true | ||
|
||
require "rgeo/geo_json" | ||
require_relative "rgeo/geo_json" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
# frozen_string_literal: true | ||
|
||
require "rgeo" | ||
require "rgeo/geo_json/version" | ||
require "rgeo/geo_json/entities" | ||
require "rgeo/geo_json/coder" | ||
require "rgeo/geo_json/interface" | ||
require_relative "geo_json/version" | ||
require_relative "geo_json/entities" | ||
require_relative "geo_json/coder" | ||
require_relative "geo_json/interface" | ||
require "multi_json" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# frozen_string_literal: true | ||
|
||
module RGeo | ||
# This module is here to fill the gap between what is a GeometryCollection (GIS) | ||
# and a FeatureCollection (GeoJSON). | ||
# | ||
# Note for contributors, you can rely on `@features` to be defined and | ||
# you can consider working with an Enumerable wrapping `@features`. See | ||
# GeoJSON::FeatureCollection. | ||
module GeoJSON::CollectionMethods | ||
# There is tight coupling between {FeatureCollection} and this, hence the | ||
# guard. | ||
private_class_method def self.included(base) | ||
return if base.to_s == "RGeo::GeoJSON::FeatureCollection" | ||
|
||
raise Error::RGeoError, "#{self.class} must only be used by FeatureCollection" | ||
end | ||
|
||
private def method_missing(symbol, *args) | ||
return super unless any? { |feature| feature.respond_to?(symbol) } | ||
|
||
raise Error::UnsupportedOperation, "Method FeatureCollection##{symbol} " \ | ||
"is not defined. You may consider filing an issue or opening a pull " \ | ||
"request at https://github.com/rgeo/rgeo-geojson" | ||
end | ||
|
||
def contains?(geometry) | ||
any? { |feature| feature.contains?(geometry) } | ||
end | ||
|
||
def intersects?(geometry) | ||
any? { |feature| feature.intersects?(geometry) } | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.