bh: thuban/libraries/pyshapelib shapelib_wrap.c, 1.1, 1.2 shapelib.i, 1.1, 1.2 pytest.py, 1.1, 1.2 ChangeLog, 1.8, 1.9
cvs@intevation.de
cvs at intevation.de
Thu Jun 30 16:20:48 CEST 2005
Author: bh
Update of /thubanrepository/thuban/libraries/pyshapelib
In directory doto:/tmp/cvs-serv7211/libraries/pyshapelib
Modified Files:
shapelib_wrap.c shapelib.i pytest.py ChangeLog
Log Message:
* shapelib.i (new_SHPObject): Fix the test for the length of the
part types. It used the wrong variable.
* shapelib_wrap.c: Regenerated from shapelib.i
* pytest.py (make_shapefile): Add some more comments and add an
example with a polygon with a hole.
Index: shapelib_wrap.c
===================================================================
RCS file: /thubanrepository/thuban/libraries/pyshapelib/shapelib_wrap.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- shapelib_wrap.c 19 Aug 2003 21:24:20 -0000 1.1
+++ shapelib_wrap.c 30 Jun 2005 14:20:46 -0000 1.2
@@ -1,6 +1,6 @@
/* ----------------------------------------------------------------------------
* This file was automatically generated by SWIG (http://www.swig.org).
- * Version 1.3u-20020503-1857 (Alpha 5)
+ * Version 1.3u-20050630-1524 (Alpha 5)
*
* This file is not intended to be easily readable and contains a number of
* coding conventions designed to improve portability and efficiency. Do not make
@@ -669,7 +669,7 @@
/* parts and part_types have to have the same lengths */
if (part_type_list
- && PySequence_Length(part) != PySequence_Length(part_type_list))
+ && PySequence_Length(parts) != PySequence_Length(part_type_list))
{
PyErr_SetString(PyExc_TypeError,
"parts and part_types have to have the same lengths");
Index: shapelib.i
===================================================================
RCS file: /thubanrepository/thuban/libraries/pyshapelib/shapelib.i,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- shapelib.i 19 Aug 2003 21:24:20 -0000 1.1
+++ shapelib.i 30 Jun 2005 14:20:46 -0000 1.2
@@ -192,7 +192,7 @@
/* parts and part_types have to have the same lengths */
if (part_type_list
- && PySequence_Length(part) != PySequence_Length(part_type_list))
+ && PySequence_Length(parts) != PySequence_Length(part_type_list))
{
PyErr_SetString(PyExc_TypeError,
"parts and part_types have to have the same lengths");
Index: pytest.py
===================================================================
RCS file: /thubanrepository/thuban/libraries/pyshapelib/pytest.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- pytest.py 19 Aug 2003 21:24:20 -0000 1.1
+++ pytest.py 30 Jun 2005 14:20:46 -0000 1.2
@@ -5,13 +5,37 @@
#
def make_shapefile(filename):
+ # Create a shapefile with polygons
+ outfile = shapelib.create(filename, shapelib.SHPT_POLYGON)
+
+ # Create one very simple polygon and write it to the shapefile. The
+ # vertices should be given in clockwise order to comply with the
+ # shapefile specification.
obj = shapelib.SHPObject(shapelib.SHPT_POLYGON, 1,
- [[(10, 10), (20, 10), (20, 20), (10, 10)]])
+ [[(10, 10), (10, 20), (20, 20), (10, 10)]])
print obj.extents()
print obj.vertices()
- outfile = shapelib.create(filename, shapelib.SHPT_POLYGON)
outfile.write_object(-1, obj)
- del outfile
+
+ # Create a polygon with a hole. Note that according to the
+ # shapefile specification, the vertices of the outer ring have to be
+ # in clockwise order and the inner rings have to be in counter
+ # clockwise order.
+ #
+ # There's an optional fourth parameter which when given must be a
+ # list of part types, one for each part of the shape. For polygons,
+ # the part type is always shapelib.SHPP_RING, though. The part
+ # types are only relevant for SHPT_MULTIPATCH shapefiles.
+ obj = shapelib.SHPObject(shapelib.SHPT_POLYGON, 1,
+ [[(0, 0), (0, 40), (40, 40), (40, 0), (0, 0)],
+ [(10, 10), (20, 10), (20, 20), (10, 20),(10, 10)],
+ ])
+ print obj.extents()
+ print obj.vertices()
+ outfile.write_object(-1, obj)
+
+ # close the file.
+ outfile.close()
def read_shapefile(filename):
# open the shapefile
Index: ChangeLog
===================================================================
RCS file: /thubanrepository/thuban/libraries/pyshapelib/ChangeLog,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- ChangeLog 27 Dec 2004 14:27:53 -0000 1.8
+++ ChangeLog 30 Jun 2005 14:20:46 -0000 1.9
@@ -1,3 +1,13 @@
+2005-06-30 Bernhard Herzog <bh at intevation.de>
+
+ * shapelib.i (new_SHPObject): Fix the test for the length of the
+ part types. It used the wrong variable.
+
+ * shapelib_wrap.c: Regenerated from shapelib.i
+
+ * pytest.py (make_shapefile): Add some more comments and add an
+ example with a polygon with a hole.
+
2004-12-27 Bernhard Reiter <bernhard at intevation.de>
* README: Refering to the new homepage shapelib.maptools.org now.
More information about the Thuban-devel
mailing list
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)