Module: OGR::GeometryTypes::Curve::Extensions

Included in:
LineString, MultiLineString
Defined in:
lib/ogr/extensions/geometry_types/curve/extensions.rb

Instance Method Summary collapse

Instance Method Details

#closed?Boolean

Returns:

  • (Boolean)


59
60
61
# File 'lib/ogr/extensions/geometry_types/curve/extensions.rb', line 59

def closed?
  start_point == end_point
end

#each_point_geometry {|| ... } ⇒ Enumerator

Yield Parameters:

Returns:

  • (Enumerator)


26
27
28
29
30
31
32
# File 'lib/ogr/extensions/geometry_types/curve/extensions.rb', line 26

def each_point_geometry
  return enum_for(:each_point_geometry) unless block_given?

  point_count.times do |point_num|
    yield point_as_geometry(point_num)
  end
end

#end_pointObject



55
56
57
# File 'lib/ogr/extensions/geometry_types/curve/extensions.rb', line 55

def end_point
  point(point_count - 1)
end

#pixels(geo_transform) ⇒ Array<Array>

Parameters:

Returns:

  • (Array<Array>)


42
43
44
45
46
47
48
49
# File 'lib/ogr/extensions/geometry_types/curve/extensions.rb', line 42

def pixels(geo_transform)
  log "points count: #{point_count}"
  points.map do |x_and_y|
    result = geo_transform.world_to_pixel(*x_and_y)

    [result[:pixel].to_i.abs, result[:line].to_i.abs]
  end
end

#point_geometriesArray<OGR::Point>

Returns:

See Also:

  • #point_geometry


36
37
38
# File 'lib/ogr/extensions/geometry_types/curve/extensions.rb', line 36

def point_geometries
  each_point_geometry.to_a
end

#point_geometry(number) ⇒ OGR::Point

It seems as if OGR::GeometryTypes::Curve::Extensions.{{#point} should return an OGR::Point, but since OGR’s OGR_G_GetPoint only returns coordinates, this allows getting the point as an OGR::Point.

Parameters:

  • number (Integer)

    Index of the point to get.

Returns:



16
17
18
19
20
21
22
# File 'lib/ogr/extensions/geometry_types/curve/extensions.rb', line 16

def point_geometry(number)
  coords = point(number)
  point = OGR::Point.new
  point.set_point(0, *coords)

  point
end

#start_pointObject



51
52
53
# File 'lib/ogr/extensions/geometry_types/curve/extensions.rb', line 51

def start_point
  point(0)
end