Module: NSWTopo::GeoJSON
- Defined in:
- lib/nswtopo/gis/geojson.rb,
lib/nswtopo/gis/geojson/point.rb,
lib/nswtopo/gis/geojson/polygon.rb,
lib/nswtopo/gis/geojson/collection.rb,
lib/nswtopo/gis/geojson/line_string.rb,
lib/nswtopo/gis/geojson/multi_point.rb,
lib/nswtopo/gis/geojson/multi_polygon.rb,
lib/nswtopo/gis/geojson/multi_line_string.rb
Defined Under Namespace
Classes: Collection, LineString, MultiLineString, MultiPoint, MultiPolygon, Point, Polygon
Constant Summary collapse
- Error =
Class.new StandardError
- TYPES =
Set.new %W[Point MultiPoint LineString MultiLineString Polygon MultiPolygon]
- CLASSES =
TYPES.map do |type| klass = Class.new do def initialize(coordinates, properties = {}) properties ||= {} raise Error, "invalid feature properties" unless Hash === properties raise Error, "invalid feature geometry" unless Array === coordinates @coordinates, @properties = coordinates, properties end attr_accessor :coordinates, :properties define_method :to_h do { "type" => "Feature", "geometry" => { "type" => type, "coordinates" => @coordinates }, "properties" => @properties } end extend Forwardable delegate %i[[] []= fetch values_at key? store clear] => :@properties end const_set type, klass end