Ejemplo n.º 1
0
 def testSubLine(self):
     line = geom.LineString((1137466.548141059, 650434.9943107369),
                            (1175272.4129268457, 648011.541439853),
                            (1185935.6055587344, 632986.1336403737))
     subLine = line.subLine(0.33, 0.67)
     assert "LINESTRING (1156010.153864557 649246.3016361536, 1175115.6870342216 648021.5879714314)" == str(
         subLine)
Ejemplo n.º 2
0
 def testCompoundRing(self):
     cc = geom.CompoundRing(
         geom.CircularString([10.0, 10.0], [0.0, 20.0], [-10.0, 10.0]),
         geom.LineString([-10.0, 10.0], [-10.0, 0.0], [10.0, 0.0],
                         [10.0, 10.0]))
     self.assertEqual(
         'COMPOUNDCURVE (CIRCULARSTRING (10.0 10.0, 0.0 20.0, -10.0 10.0), (-10.0 10.0, -10.0 0.0, 10.0 0.0, 10.0 10.0))',
         str(cc))
Ejemplo n.º 3
0
    def testBounds(self):
        g = geom.LineString((1, 1), (10, 10))
        f = feature.Feature({'geom': g}, 'fid')

        assert 1 == f.bounds.west
        assert 1 == f.bounds.south
        assert 10 == f.bounds.east
        assert 10 == f.bounds.north
Ejemplo n.º 4
0
 def testPlacePoint(self):
     line = geom.LineString((1137466.548141059, 650434.9943107369),
                            (1175272.4129268457, 648011.541439853),
                            (1185935.6055587344, 632986.1336403737))
     point1 = geom.Point(1153461.34, 649950.30)
     point2 = line.placePoint(point1)
     assert "POINT (1153426.8271476042 649411.899502625)" == str(point2)
     point3 = line.placePoint(1153461.34, 649950.30)
     assert "POINT (1153426.8271476042 649411.899502625)" == str(point3)
Ejemplo n.º 5
0
 def testLocatePoint(self):
     line = geom.LineString((1137466.548141059, 650434.9943107369),
                            (1175272.4129268457, 648011.541439853),
                            (1185935.6055587344, 632986.1336403737))
     point = geom.Point(1153461.34, 649950.30)
     position = line.locatePoint(point)
     self.assertAlmostEqual(0.284, position, places=3)
     position = line.locatePoint(1153461.34, 649950.30)
     self.assertAlmostEqual(0.284, position, places=3)
Ejemplo n.º 6
0
    def testWriteGML(self):
        gml = geom.writeGML(geom.Point(1, 2))
        p = geom.readGML(gml)
        assert 1.0 == p.x and 2.0 == p.y

        line = geom.LineString([1, 2], [3, 4])
        assert str(line) == str(geom.readGML(geom.writeGML(line, ver=3),
                                             ver=3))

        poly = geom.Polygon([[1, 2], [3, 4], [5, 6], [1, 2]])
        assert str(poly) == str(
            geom.readGML(geom.writeGML(poly, ver=3.2), ver=3.2))
Ejemplo n.º 7
0
    def testInterpolatePoint(self):
        line = geom.LineString((1137466.548141059, 650434.9943107369),
                               (1175272.4129268457, 648011.541439853),
                               (1185935.6055587344, 632986.1336403737))

        # start
        point1 = line.interpolatePoint(0)
        assert str(line.startPoint) == str(point1)

        # middle
        point2 = line.interpolatePoint(0.5)
        assert "POINT (1165562.9204493894 648633.9448037925)" == str(point2)

        # end
        point3 = line.interpolatePoint(1.0)
        assert str(line.endPoint) == str(point3)
Ejemplo n.º 8
0
 def testLineStringFromJTS(self):
     ls = self.gf.createLineString([Coordinate(1, 2), Coordinate(3, 4)])
     l = geom.LineString(ls)
     self.assertEqual('LINESTRING (1 2, 3 4)', str(l))
Ejemplo n.º 9
0
 def testLineString(self):
     l = geom.LineString((1, 2), (3, 4))
     self.assertEqual('LINESTRING (1 2, 3 4)', str(l))