Sha256: 53a07fcd81495e291d5e96aef0871529492febf1e0ff86c0908b38af25940168

Contents?: true

Size: 1.56 KB

Versions: 5

Compression:

Stored size: 1.56 KB

Contents

# -----------------------------------------------------------------------------
#
# Tests for the GEOS polygon implementation
#
# -----------------------------------------------------------------------------

require "test/unit"
require "rgeo"

require ::File.expand_path("../common/polygon_tests.rb", ::File.dirname(__FILE__))

module RGeo
  module Tests # :nodoc:
    module GeosFFI # :nodoc:
      class TestPolygon < ::Test::Unit::TestCase # :nodoc:
        def setup
          @factory = ::RGeo::Geos.factory(native_interface: :ffi)
        end

        include ::RGeo::Tests::Common::PolygonTests

        def test_intersection
          point1_ = @factory.point(0, 0)
          point2_ = @factory.point(0, 2)
          point3_ = @factory.point(2, 2)
          point4_ = @factory.point(2, 0)
          poly1_ = @factory.polygon(@factory.linear_ring([point1_, point2_, point3_, point4_]))
          poly2_ = @factory.polygon(@factory.linear_ring([point1_, point2_, point4_]))
          poly3_ = poly1_.intersection(poly2_)
          assert_equal(poly2_, poly3_)
        end

        def test_union
          point1_ = @factory.point(0, 0)
          point2_ = @factory.point(0, 2)
          point3_ = @factory.point(2, 2)
          point4_ = @factory.point(2, 0)
          poly1_ = @factory.polygon(@factory.linear_ring([point1_, point2_, point3_, point4_]))
          poly2_ = @factory.polygon(@factory.linear_ring([point1_, point2_, point4_]))
          poly3_ = poly1_.union(poly2_)
          assert_equal(poly1_, poly3_)
        end
      end
    end
  end
end if ::RGeo::Geos.ffi_supported?

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
rgeo-dschee-0.5.4 test/geos_ffi/polygon_test.rb
rgeo-0.5.3 test/geos_ffi/polygon_test.rb
rgeo-0.5.2 test/geos_ffi/tc_polygon.rb
rgeo-0.5.1 test/geos_ffi/tc_polygon.rb
rgeo-0.5.0 test/geos_ffi/tc_polygon.rb