module OGR::GeometryMixins::Extensions
Public Instance Methods
!=(other)
click to toggle source
# File lib/ogr/extensions/geometry/extensions.rb, line 43 def !=(other) !equals?(other) end
collection?()
click to toggle source
# File lib/ogr/extensions/geometry/extensions.rb, line 52 def collection? false end
container?()
click to toggle source
@return [Boolean]
# File lib/ogr/extensions/geometry/extensions.rb, line 29 def container? self.class.ancestors.include? OGR::GeometryTypes::Container end
curve?()
click to toggle source
@return [Boolean]
# File lib/ogr/extensions/geometry/extensions.rb, line 34 def curve? self.class.ancestors.include? OGR::GeometryTypes::Curve end
invalid?()
click to toggle source
@return [Boolean]
# File lib/ogr/extensions/geometry/extensions.rb, line 48 def invalid? !valid? end
surface?()
click to toggle source
@return [Boolean]
# File lib/ogr/extensions/geometry/extensions.rb, line 39 def surface? self.class.ancestors.include? OGR::GeometryTypes::Surface end
to_vector(file_name, driver, layer_name: "vectorized_geometry", spatial_reference: nil)
click to toggle source
# File lib/ogr/extensions/geometry/extensions.rb, line 56 def to_vector(file_name, driver, layer_name: "vectorized_geometry", spatial_reference: nil) driver = OGR::Driver.by_name(driver) data_source = driver.create_data_source(file_name) log "Creating layer #{layer_name}, type: #{type}" layer = data_source.create_layer(layer_name, geometry_type: type, spatial_reference: spatial_reference) # field = FieldDefinition.new('Name', :OFTString) # field.width = 32 raise OGR::InvalidLayer, "Unable to create layer '#{layer_name}'." unless layer feature = layer.create_feature(layer_name) feature.geometry = self data_source end
utm_zone()
click to toggle source
@return [Integer] The number of the UTM zone this geometry belongs to.
# File lib/ogr/extensions/geometry/extensions.rb, line 9 def utm_zone return unless spatial_reference self_as4326 = if spatial_reference.authority_code == "4326" self else # NOTE: #clone here has overridden Ruby's clone and calls OGR_G_Clone; # it's important to do this and clone.tap { |as4326| as4326.transform_to!(OGR::SpatialReference.new.import_from_epsg(4326)) } end self_as4326 = self_as4326.buffer(0) unless valid? return unless self_as4326.point_on_surface.x ((self_as4326.point_on_surface.x + 180) / 6.to_f).floor + 1 end