desc stringlengths 3 26.7k | decl stringlengths 11 7.89k | bodies stringlengths 8 553k |
|---|---|---|
'Testing EWKT.'
| def test01h_ewkt(self):
| srid = 32140
for p in self.geometries.polygons:
ewkt = ('SRID=%d;%s' % (srid, p.wkt))
poly = fromstr(ewkt)
self.assertEqual(srid, poly.srid)
self.assertEqual(srid, poly.shell.srid)
self.assertEqual(srid, fromstr(poly.ewkt).srid)
|
'Testing GeoJSON input/output (via GDAL).'
| def test01i_json(self):
| if ((not gdal) or (not gdal.GEOJSON)):
return
for g in self.geometries.json_geoms:
geom = GEOSGeometry(g.wkt)
if (not hasattr(g, 'not_equal')):
self.assertEqual(g.json, geom.json)
self.assertEqual(g.json, geom.geojson)
self.assertEqual(GEOSGeometry(g.wkt),... |
'Testing the fromfile() factory.'
| def test01k_fromfile(self):
| from StringIO import StringIO
ref_pnt = GEOSGeometry('POINT(5 23)')
wkt_f = StringIO()
wkt_f.write(ref_pnt.wkt)
wkb_f = StringIO()
wkb_f.write(str(ref_pnt.wkb))
for fh in (wkt_f, wkb_f):
fh.seek(0)
pnt = fromfile(fh)
self.assertEqual(ref_pnt, pnt)
|
'Testing equivalence.'
| def test01k_eq(self):
| p = fromstr('POINT(5 23)')
self.assertEqual(p, p.wkt)
self.assertNotEqual(p, 'foo')
ls = fromstr('LINESTRING(0 0, 1 1, 5 5)')
self.assertEqual(ls, ls.wkt)
self.assertNotEqual(p, 'bar')
for g in (p, ls):
self.assertNotEqual(g, None)
self.assertNotEqual(g, {'f... |
'Testing Point objects.'
| def test02a_points(self):
| prev = fromstr('POINT(0 0)')
for p in self.geometries.points:
pnt = fromstr(p.wkt)
self.assertEqual(pnt.geom_type, 'Point')
self.assertEqual(pnt.geom_typeid, 0)
self.assertEqual(p.x, pnt.x)
self.assertEqual(p.y, pnt.y)
self.assertEqual(True, (pnt == fromstr(p.w... |
'Testing MultiPoint objects.'
| def test02b_multipoints(self):
| for mp in self.geometries.multipoints:
mpnt = fromstr(mp.wkt)
self.assertEqual(mpnt.geom_type, 'MultiPoint')
self.assertEqual(mpnt.geom_typeid, 4)
self.assertAlmostEqual(mp.centroid[0], mpnt.centroid.tuple[0], 9)
self.assertAlmostEqual(mp.centroid[1], mpnt.centroid.tuple[1], ... |
'Testing LineString objects.'
| def test03a_linestring(self):
| prev = fromstr('POINT(0 0)')
for l in self.geometries.linestrings:
ls = fromstr(l.wkt)
self.assertEqual(ls.geom_type, 'LineString')
self.assertEqual(ls.geom_typeid, 1)
self.assertEqual(ls.empty, False)
self.assertEqual(ls.ring, False)
if hasattr(l, 'centroid'):... |
'Testing MultiLineString objects.'
| def test03b_multilinestring(self):
| prev = fromstr('POINT(0 0)')
for l in self.geometries.multilinestrings:
ml = fromstr(l.wkt)
self.assertEqual(ml.geom_type, 'MultiLineString')
self.assertEqual(ml.geom_typeid, 5)
self.assertAlmostEqual(l.centroid[0], ml.centroid.x, 9)
self.assertAlmostEqual(l.centroid[1... |
'Testing LinearRing objects.'
| def test04_linearring(self):
| for rr in self.geometries.linearrings:
lr = fromstr(rr.wkt)
self.assertEqual(lr.geom_type, 'LinearRing')
self.assertEqual(lr.geom_typeid, 2)
self.assertEqual(rr.n_p, len(lr))
self.assertEqual(True, lr.valid)
self.assertEqual(False, lr.empty)
self.assertEqual(l... |
'Testing Polygon objects.'
| def test05a_polygons(self):
| bbox = ((-180), (-90), 180, 90)
p = Polygon.from_bbox(bbox)
self.assertEqual(bbox, p.extent)
prev = fromstr('POINT(0 0)')
for p in self.geometries.polygons:
poly = fromstr(p.wkt)
self.assertEqual(poly.geom_type, 'Polygon')
self.assertEqual(poly.geom_typeid, 3)
self... |
'Testing MultiPolygon objects.'
| def test05b_multipolygons(self):
| print '\nBEGIN - expecting GEOS_NOTICE; safe to ignore.\n'
prev = fromstr('POINT (0 0)')
for mp in self.geometries.multipolygons:
mpoly = fromstr(mp.wkt)
self.assertEqual(mpoly.geom_type, 'MultiPolygon')
self.assertEqual(mpoly.geom_typeid, 6)
self.asse... |
'Testing Geometry __del__() on rings and polygons.'
| def test06a_memory_hijinks(self):
| poly = fromstr(self.geometries.polygons[1].wkt)
ring1 = poly[0]
ring2 = poly[1]
del ring1
del ring2
ring1 = poly[0]
ring2 = poly[1]
del poly
(s1, s2) = (str(ring1), str(ring2))
|
'Testing Coordinate Sequence objects.'
| def test08_coord_seq(self):
| for p in self.geometries.polygons:
if p.ext_ring_cs:
poly = fromstr(p.wkt)
cs = poly.exterior_ring.coord_seq
self.assertEqual(p.ext_ring_cs, cs.tuple)
self.assertEqual(len(p.ext_ring_cs), len(cs))
for i in xrange(len(p.ext_ring_cs)):
... |
'Testing relate() and relate_pattern().'
| def test09_relate_pattern(self):
| g = fromstr('POINT (0 0)')
self.assertRaises(GEOSException, g.relate_pattern, 0, 'invalid pattern, yo')
for rg in self.geometries.relate_geoms:
a = fromstr(rg.wkt_a)
b = fromstr(rg.wkt_b)
self.assertEqual(rg.result, a.relate_pattern(b, rg.pattern))
self.assertEqua... |
'Testing intersects() and intersection().'
| def test10_intersection(self):
| for i in xrange(len(self.geometries.topology_geoms)):
a = fromstr(self.geometries.topology_geoms[i].wkt_a)
b = fromstr(self.geometries.topology_geoms[i].wkt_b)
i1 = fromstr(self.geometries.intersect_geoms[i].wkt)
self.assertEqual(True, a.intersects(b))
i2 = a.intersection(b)
... |
'Testing union().'
| def test11_union(self):
| for i in xrange(len(self.geometries.topology_geoms)):
a = fromstr(self.geometries.topology_geoms[i].wkt_a)
b = fromstr(self.geometries.topology_geoms[i].wkt_b)
u1 = fromstr(self.geometries.union_geoms[i].wkt)
u2 = a.union(b)
self.assertEqual(u1, u2)
self.assertEqual(u... |
'Testing difference().'
| def test12_difference(self):
| for i in xrange(len(self.geometries.topology_geoms)):
a = fromstr(self.geometries.topology_geoms[i].wkt_a)
b = fromstr(self.geometries.topology_geoms[i].wkt_b)
d1 = fromstr(self.geometries.diff_geoms[i].wkt)
d2 = a.difference(b)
self.assertEqual(d1, d2)
self.assertEqu... |
'Testing sym_difference().'
| def test13_symdifference(self):
| for i in xrange(len(self.geometries.topology_geoms)):
a = fromstr(self.geometries.topology_geoms[i].wkt_a)
b = fromstr(self.geometries.topology_geoms[i].wkt_b)
d1 = fromstr(self.geometries.sdiff_geoms[i].wkt)
d2 = a.sym_difference(b)
self.assertEqual(d1, d2)
self.asse... |
'Testing buffer().'
| def test14_buffer(self):
| for bg in self.geometries.buffer_geoms:
g = fromstr(bg.wkt)
exp_buf = fromstr(bg.buffer_wkt)
quadsegs = bg.quadsegs
width = bg.width
self.assertRaises(ctypes.ArgumentError, g.buffer, width, float(quadsegs))
buf = g.buffer(width, quadsegs)
self.assertEqual(exp_... |
'Testing the SRID property and keyword.'
| def test15_srid(self):
| pnt = Point(5, 23, srid=4326)
self.assertEqual(4326, pnt.srid)
pnt.srid = 3084
self.assertEqual(3084, pnt.srid)
self.assertRaises(ctypes.ArgumentError, pnt.set_srid, '4326')
poly = fromstr(self.geometries.polygons[1].wkt, srid=4269)
self.assertEqual(4269, poly.srid)
for ring in poly:
... |
'Testing the mutability of Polygons and Geometry Collections.'
| def test16_mutable_geometries(self):
| for p in self.geometries.polygons:
poly = fromstr(p.wkt)
self.assertRaises(TypeError, poly.__setitem__, 0, LineString((1, 1), (2, 2)))
shell_tup = poly.shell.tuple
new_coords = []
for point in shell_tup:
new_coords.append(((point[0] + 500.0), (point[1] + 500.0)))
... |
'Testing three-dimensional geometries.'
| def test17_threed(self):
| pnt = Point(2, 3, 8)
self.assertEqual((2.0, 3.0, 8.0), pnt.coords)
self.assertRaises(TypeError, pnt.set_coords, (1.0, 2.0))
pnt.coords = (1.0, 2.0, 3.0)
self.assertEqual((1.0, 2.0, 3.0), pnt.coords)
ls = LineString((2.0, 3.0, 8.0), (50.0, 250.0, (-117.0)))
self.assertEqual(((2.0, 3.0, 8.0), ... |
'Testing the distance() function.'
| def test18_distance(self):
| pnt = Point(0, 0)
self.assertEqual(0.0, pnt.distance(Point(0, 0)))
self.assertEqual(1.0, pnt.distance(Point(0, 1)))
self.assertAlmostEqual(1.41421356237, pnt.distance(Point(1, 1)), 11)
ls1 = LineString((0, 0), (1, 1), (2, 2))
ls2 = LineString((5, 2), (6, 1), (7, 0))
self.assertEqual(3, ls1.d... |
'Testing the length property.'
| def test19_length(self):
| pnt = Point(0, 0)
self.assertEqual(0.0, pnt.length)
ls = LineString((0, 0), (1, 1))
self.assertAlmostEqual(1.41421356237, ls.length, 11)
poly = Polygon(LinearRing((0, 0), (0, 1), (1, 1), (1, 0), (0, 0)))
self.assertEqual(4.0, poly.length)
mpoly = MultiPolygon(poly.clone(), poly)
self.ass... |
'Testing empty geometries and collections.'
| def test20a_emptyCollections(self):
| gc1 = GeometryCollection([])
gc2 = fromstr('GEOMETRYCOLLECTION EMPTY')
pnt = fromstr('POINT EMPTY')
ls = fromstr('LINESTRING EMPTY')
poly = fromstr('POLYGON EMPTY')
mls = fromstr('MULTILINESTRING EMPTY')
mpoly1 = fromstr('MULTIPOLYGON EMPTY')
mpoly2 = MultiPolygon(())
... |
'Testing GeometryCollection handling of other collections.'
| def test20b_collections_of_collections(self):
| coll = [mp.wkt for mp in self.geometries.multipolygons if mp.valid]
coll.extend([mls.wkt for mls in self.geometries.multilinestrings])
coll.extend([p.wkt for p in self.geometries.polygons])
coll.extend([mp.wkt for mp in self.geometries.multipoints])
gc_wkt = ('GEOMETRYCOLLECTION(%s)' % ','.join(coll... |
'Testing `ogr` and `srs` properties.'
| def test21_test_gdal(self):
| if (not gdal.HAS_GDAL):
return
g1 = fromstr('POINT(5 23)')
self.assertEqual(True, isinstance(g1.ogr, gdal.OGRGeometry))
self.assertEqual(g1.srs, None)
g2 = fromstr('LINESTRING(0 0, 5 5, 23 23)', srid=4326)
self.assertEqual(True, isinstance(g2.ogr, gdal.OGRGeometry))
... |
'Testing use with the Python `copy` module.'
| def test22_copy(self):
| import django.utils.copycompat as copy
poly = GEOSGeometry('POLYGON((0 0, 0 23, 23 23, 23 0, 0 0), (5 5, 5 10, 10 10, 10 5, 5 5))')
cpy1 = copy.copy(poly)
cpy2 = copy.deepcopy(poly)
self.assertNotEqual(poly._ptr, cpy1._ptr)
self.assertNotE... |
'Testing `transform` method.'
| def test23_transform(self):
| if (not gdal.HAS_GDAL):
return
orig = GEOSGeometry('POINT (-104.609 38.255)', 4326)
trans = GEOSGeometry('POINT (992385.4472045 481455.4944650)', 2774)
(t1, t2, t3) = (orig.clone(), orig.clone(), orig.clone())
t1.transform(trans.srid)
t2.transform(gdal.SpatialReference('EPSG:... |
'Testing `transform` method (SRID match)'
| def test23_transform_noop(self):
| if gdal.HAS_GDAL:
g = GEOSGeometry('POINT (-104.609 38.255)', 4326)
gt = g.tuple
g.transform(4326)
self.assertEqual(g.tuple, gt)
self.assertEqual(g.srid, 4326)
g = GEOSGeometry('POINT (-104.609 38.255)', 4326)
g1 = g.transform(4326, clone=True)
... |
'Testing `transform` method (no SRID)'
| def test23_transform_nosrid(self):
| import warnings
print '\nBEGIN - expecting Warnings; safe to ignore.\n'
try:
warnings.simplefilter('once', UserWarning)
warnings.simplefilter('once', FutureWarning)
g = GEOSGeometry('POINT (-104.609 38.255)', srid=None)
g.transform(2774)
self.a... |
'Testing `transform` method (GDAL not available)'
| def test23_transform_nogdal(self):
| old_has_gdal = gdal.HAS_GDAL
try:
gdal.HAS_GDAL = False
g = GEOSGeometry('POINT (-104.609 38.255)', 4326)
self.assertRaises(GEOSException, g.transform, 2774)
g = GEOSGeometry('POINT (-104.609 38.255)', 4326)
self.assertRaises(GEOSException, g.transform, 2774, ... |
'Testing `extent` method.'
| def test24_extent(self):
| mp = MultiPoint(Point(5, 23), Point(0, 0), Point(10, 50))
self.assertEqual((0.0, 0.0, 10.0, 50.0), mp.extent)
pnt = Point(5.23, 17.8)
self.assertEqual((5.23, 17.8, 5.23, 17.8), pnt.extent)
poly = fromstr(self.geometries.polygons[3].wkt)
ring = poly.shell
(x, y) = (ring.x, ring.y)
(xmin, ... |
'Testing pickling and unpickling support.'
| def test25_pickle(self):
| import pickle, cPickle
def get_geoms(lst, srid=None):
return [GEOSGeometry(tg.wkt, srid) for tg in lst]
tgeoms = get_geoms(self.geometries.points)
tgeoms.extend(get_geoms(self.geometries.multilinestrings, 4326))
tgeoms.extend(get_geoms(self.geometries.polygons, 3084))
tgeoms.extend(get_g... |
'Testing PreparedGeometry support.'
| def test26_prepared(self):
| if (not GEOS_PREPARE):
return
mpoly = GEOSGeometry('MULTIPOLYGON(((0 0,0 5,5 5,5 0,0 0)),((5 5,5 10,10 10,10 5,5 5)))')
prep = mpoly.prepared
pnts = [Point(5, 5), Point(7.5, 7.5), Point(2.5, 7.5)]
covers = [True, True, False]
for (pnt, c) in zip(pnts, covers... |
'Testing line merge support'
| def test26_line_merge(self):
| ref_geoms = (fromstr('LINESTRING(1 1, 1 1, 3 3)'), fromstr('MULTILINESTRING((1 1, 3 3), (3 3, 4 2))'))
ref_merged = (fromstr('LINESTRING(1 1, 3 3)'), fromstr('LINESTRING (1 1, 3 3, 4 2)'))
for (geom, merged) in zip(ref_geoms, ref_merged):
... |
'Testing IsValidReason support'
| def test27_valid_reason(self):
| if (not GEOS_PREPARE):
return
g = GEOSGeometry('POINT(0 0)')
self.assertTrue(g.valid)
self.assertTrue(isinstance(g.valid_reason, basestring))
self.assertEqual(g.valid_reason, 'Valid Geometry')
print '\nBEGIN - expecting GEOS_NOTICE; safe to ignore.\n'
g = GEOS... |
'The base constructor for GEOS geometry objects, and may take the
following inputs:
* strings:
- WKT
- HEXEWKB (a PostGIS-specific canonical form)
- GeoJSON (requires GDAL)
* buffer:
- WKB
The `srid` keyword is used to specify the Source Reference Identifier
(SRID) number for this Geometry. If not set, the SRID will b... | def __init__(self, geo_input, srid=None):
| if isinstance(geo_input, basestring):
if isinstance(geo_input, unicode):
geo_input = geo_input.encode('ascii')
wkt_m = wkt_regex.match(geo_input)
if wkt_m:
if wkt_m.group('srid'):
srid = int(wkt_m.group('srid'))
g = wkt_r().read(wkt_m.group... |
'Helper routine for performing post-initialization setup.'
| def _post_init(self, srid):
| if (srid and isinstance(srid, int)):
self.srid = srid
self.__class__ = GEOS_CLASSES[self.geom_typeid]
self._set_cs()
|
'Destroys this Geometry; in other words, frees the memory used by the
GEOS C++ object.'
| def __del__(self):
| if self._ptr:
capi.destroy_geom(self._ptr)
|
'Returns a clone because the copy of a GEOSGeometry may contain an
invalid pointer location if the original is garbage collected.'
| def __copy__(self):
| return self.clone()
|
'The `deepcopy` routine is used by the `Node` class of django.utils.tree;
thus, the protocol routine needs to be implemented to return correct
copies (clones) of these GEOS objects, which use C pointers.'
| def __deepcopy__(self, memodict):
| return self.clone()
|
'WKT is used for the string representation.'
| def __str__(self):
| return self.wkt
|
'Short-hand representation because WKT may be very large.'
| def __repr__(self):
| return ('<%s object at %s>' % (self.geom_type, hex(addressof(self.ptr))))
|
'Equivalence testing, a Geometry may be compared with another Geometry
or a WKT representation.'
| def __eq__(self, other):
| if isinstance(other, basestring):
return (self.wkt == other)
elif isinstance(other, GEOSGeometry):
return self.equals_exact(other)
else:
return False
|
'The not equals operator.'
| def __ne__(self, other):
| return (not (self == other))
|
'Returns the union of this Geometry and the other.'
| def __or__(self, other):
| return self.union(other)
|
'Returns the intersection of this Geometry and the other.'
| def __and__(self, other):
| return self.intersection(other)
|
'Return the difference this Geometry and the other.'
| def __sub__(self, other):
| return self.difference(other)
|
'Return the symmetric difference of this Geometry and the other.'
| def __xor__(self, other):
| return self.sym_difference(other)
|
'Returns True if this Geometry has a coordinate sequence, False if not.'
| @property
def has_cs(self):
| if isinstance(self, (Point, LineString, LinearRing)):
return True
else:
return False
|
'Sets the coordinate sequence for this Geometry.'
| def _set_cs(self):
| if self.has_cs:
self._cs = GEOSCoordSeq(capi.get_cs(self.ptr), self.hasz)
else:
self._cs = None
|
'Returns a clone of the coordinate sequence for this Geometry.'
| @property
def coord_seq(self):
| if self.has_cs:
return self._cs.clone()
|
'Returns a string representing the Geometry type, e.g. \'Polygon\''
| @property
def geom_type(self):
| return capi.geos_type(self.ptr)
|
'Returns an integer representing the Geometry type.'
| @property
def geom_typeid(self):
| return capi.geos_typeid(self.ptr)
|
'Returns the number of geometries in the Geometry.'
| @property
def num_geom(self):
| return capi.get_num_geoms(self.ptr)
|
'Returns the number of coordinates in the Geometry.'
| @property
def num_coords(self):
| return capi.get_num_coords(self.ptr)
|
'Returns the number points, or coordinates, in the Geometry.'
| @property
def num_points(self):
| return self.num_coords
|
'Returns the dimension of this Geometry (0=point, 1=line, 2=surface).'
| @property
def dims(self):
| return capi.get_dims(self.ptr)
|
'Converts this Geometry to normal form (or canonical form).'
| def normalize(self):
| return capi.geos_normalize(self.ptr)
|
'Returns a boolean indicating whether the set of points in this Geometry
are empty.'
| @property
def empty(self):
| return capi.geos_isempty(self.ptr)
|
'Returns whether the geometry has a 3D dimension.'
| @property
def hasz(self):
| return capi.geos_hasz(self.ptr)
|
'Returns whether or not the geometry is a ring.'
| @property
def ring(self):
| return capi.geos_isring(self.ptr)
|
'Returns false if the Geometry not simple.'
| @property
def simple(self):
| return capi.geos_issimple(self.ptr)
|
'This property tests the validity of this Geometry.'
| @property
def valid(self):
| return capi.geos_isvalid(self.ptr)
|
'Returns a string containing the reason for any invalidity.'
| @property
def valid_reason(self):
| if (not GEOS_PREPARE):
raise GEOSException('Upgrade GEOS to 3.1 to get validity reason.')
return capi.geos_isvalidreason(self.ptr)
|
'Returns true if other.within(this) returns true.'
| def contains(self, other):
| return capi.geos_contains(self.ptr, other.ptr)
|
'Returns true if the DE-9IM intersection matrix for the two Geometries
is T*T****** (for a point and a curve,a point and an area or a line and
an area) 0******** (for two curves).'
| def crosses(self, other):
| return capi.geos_crosses(self.ptr, other.ptr)
|
'Returns true if the DE-9IM intersection matrix for the two Geometries
is FF*FF****.'
| def disjoint(self, other):
| return capi.geos_disjoint(self.ptr, other.ptr)
|
'Returns true if the DE-9IM intersection matrix for the two Geometries
is T*F**FFF*.'
| def equals(self, other):
| return capi.geos_equals(self.ptr, other.ptr)
|
'Returns true if the two Geometries are exactly equal, up to a
specified tolerance.'
| def equals_exact(self, other, tolerance=0):
| return capi.geos_equalsexact(self.ptr, other.ptr, float(tolerance))
|
'Returns true if disjoint returns false.'
| def intersects(self, other):
| return capi.geos_intersects(self.ptr, other.ptr)
|
'Returns true if the DE-9IM intersection matrix for the two Geometries
is T*T***T** (for two points or two surfaces) 1*T***T** (for two curves).'
| def overlaps(self, other):
| return capi.geos_overlaps(self.ptr, other.ptr)
|
'Returns true if the elements in the DE-9IM intersection matrix for the
two Geometries match the elements in pattern.'
| def relate_pattern(self, other, pattern):
| if ((not isinstance(pattern, basestring)) or (len(pattern) > 9)):
raise GEOSException('invalid intersection matrix pattern')
return capi.geos_relatepattern(self.ptr, other.ptr, pattern)
|
'Returns true if the DE-9IM intersection matrix for the two Geometries
is FT*******, F**T***** or F***T****.'
| def touches(self, other):
| return capi.geos_touches(self.ptr, other.ptr)
|
'Returns true if the DE-9IM intersection matrix for the two Geometries
is T*F**F***.'
| def within(self, other):
| return capi.geos_within(self.ptr, other.ptr)
|
'Gets the SRID for the geometry, returns None if no SRID is set.'
| def get_srid(self):
| s = capi.geos_get_srid(self.ptr)
if (s == 0):
return None
else:
return s
|
'Sets the SRID for the geometry.'
| def set_srid(self, srid):
| capi.geos_set_srid(self.ptr, srid)
|
'Returns the EWKT (WKT + SRID) of the Geometry. Note that Z values
are *not* included in this representation because GEOS does not yet
support serializing them.'
| @property
def ewkt(self):
| if self.get_srid():
return ('SRID=%s;%s' % (self.srid, self.wkt))
else:
return self.wkt
|
'Returns the WKT (Well-Known Text) representation of this Geometry.'
| @property
def wkt(self):
| return wkt_w().write(self)
|
'Returns the WKB of this Geometry in hexadecimal form. Please note
that the SRID and Z values are not included in this representation
because it is not a part of the OGC specification (use the `hexewkb`
property instead).'
| @property
def hex(self):
| return wkb_w().write_hex(self)
|
'Returns the EWKB of this Geometry in hexadecimal form. This is an
extension of the WKB specification that includes SRID and Z values
that are a part of this geometry.'
| @property
def hexewkb(self):
| if self.hasz:
if (not GEOS_PREPARE):
raise GEOSException('Upgrade GEOS to 3.1 to get valid 3D HEXEWKB.')
return ewkb_w3d().write_hex(self)
else:
return ewkb_w().write_hex(self)
|
'Returns GeoJSON representation of this Geometry if GDAL 1.5+
is installed.'
| @property
def json(self):
| if gdal.GEOJSON:
return self.ogr.json
else:
raise GEOSException('GeoJSON output only supported on GDAL 1.5+.')
|
'Returns the WKB (Well-Known Binary) representation of this Geometry
as a Python buffer. SRID and Z values are not included, use the
`ewkb` property instead.'
| @property
def wkb(self):
| return wkb_w().write(self)
|
'Return the EWKB representation of this Geometry as a Python buffer.
This is an extension of the WKB specification that includes any SRID
and Z values that are a part of this geometry.'
| @property
def ewkb(self):
| if self.hasz:
if (not GEOS_PREPARE):
raise GEOSException('Upgrade GEOS to 3.1 to get valid 3D EWKB.')
return ewkb_w3d().write(self)
else:
return ewkb_w().write(self)
|
'Returns the KML representation of this Geometry.'
| @property
def kml(self):
| gtype = self.geom_type
return ('<%s>%s</%s>' % (gtype, self.coord_seq.kml, gtype))
|
'Returns a PreparedGeometry corresponding to this geometry -- it is
optimized for the contains, intersects, and covers operations.'
| @property
def prepared(self):
| if GEOS_PREPARE:
return PreparedGeometry(self)
else:
raise GEOSException('GEOS 3.1+ required for prepared geometry support.')
|
'Returns the OGR Geometry for this Geometry.'
| @property
def ogr(self):
| if gdal.HAS_GDAL:
if self.srid:
return gdal.OGRGeometry(self.wkb, self.srid)
else:
return gdal.OGRGeometry(self.wkb)
else:
raise GEOSException('GDAL required to convert to an OGRGeometry.')
|
'Returns the OSR SpatialReference for SRID of this Geometry.'
| @property
def srs(self):
| if gdal.HAS_GDAL:
if self.srid:
return gdal.SpatialReference(self.srid)
else:
return None
else:
raise GEOSException('GDAL required to return a SpatialReference object.')
|
'Alias for `srs` property.'
| @property
def crs(self):
| return self.srs
|
'Requires GDAL. Transforms the geometry according to the given
transformation object, which may be an integer SRID, and WKT or
PROJ.4 string. By default, the geometry is transformed in-place and
nothing is returned. However if the `clone` keyword is set, then this
geometry will not be modified and a transformed clone w... | def transform(self, ct, clone=False):
| srid = self.srid
if (ct == srid):
if clone:
return self.clone()
else:
return
if ((srid is None) or (srid < 0)):
warnings.warn('Calling transform() with no SRID set does no transformation!', stacklevel=2)
warnings.warn('Calling ... |
'Helper routine to return Geometry from the given pointer.'
| def _topology(self, gptr):
| return GEOSGeometry(gptr, srid=self.srid)
|
'Returns the boundary as a newly allocated Geometry object.'
| @property
def boundary(self):
| return self._topology(capi.geos_boundary(self.ptr))
|
'Returns a geometry that represents all points whose distance from this
Geometry is less than or equal to distance. Calculations are in the
Spatial Reference System of this Geometry. The optional third parameter sets
the number of segment used to approximate a quarter circle (defaults to 8).
(Text from PostGIS document... | def buffer(self, width, quadsegs=8):
| return self._topology(capi.geos_buffer(self.ptr, width, quadsegs))
|
'The centroid is equal to the centroid of the set of component Geometries
of highest dimension (since the lower-dimension geometries contribute zero
"weight" to the centroid).'
| @property
def centroid(self):
| return self._topology(capi.geos_centroid(self.ptr))
|
'Returns the smallest convex Polygon that contains all the points
in the Geometry.'
| @property
def convex_hull(self):
| return self._topology(capi.geos_convexhull(self.ptr))
|
'Returns a Geometry representing the points making up this Geometry
that do not make up other.'
| def difference(self, other):
| return self._topology(capi.geos_difference(self.ptr, other.ptr))
|
'Return the envelope for this geometry (a polygon).'
| @property
def envelope(self):
| return self._topology(capi.geos_envelope(self.ptr))
|
'Returns a Geometry representing the points shared by this Geometry and other.'
| def intersection(self, other):
| return self._topology(capi.geos_intersection(self.ptr, other.ptr))
|
'Computes an interior point of this Geometry.'
| @property
def point_on_surface(self):
| return self._topology(capi.geos_pointonsurface(self.ptr))
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.