This is an automated email from the git hooks/post-receive script.

sebastic pushed a commit to branch master
in repository python-shapely.

commit 25b6849ecebba82631c83dfc94994733aaa90a31
Author: Pietro Battiston <m...@pietrobattiston.it>
Date:   Tue Sep 14 11:11:08 2010 +0200

    Imported Upstream version 1.2.3
---
 CHANGES.txt                          |  5 +++++
 PKG-INFO                             |  2 +-
 Shapely.egg-info/PKG-INFO            |  2 +-
 Shapely.egg-info/SOURCES.txt         |  1 +
 docs/_build/html/_sources/manual.txt | 35 +++++++++++++++++++++++++----------
 docs/manual.txt                      | 30 +++++++++++++++++++++++++-----
 setup.py                             |  2 +-
 shapely/ctypes_declarations.py       |  6 +++---
 shapely/geometry/__init__.py         |  4 ++--
 shapely/geometry/base.py             |  9 ++++++---
 shapely/geometry/geo.py              |  4 ++++
 shapely/geos.py                      |  4 ++--
 shapely/tests/__init__.py            |  2 ++
 shapely/tests/test_mapping.py        | 11 +++++++++++
 shapely/validation.py                |  2 +-
 15 files changed, 90 insertions(+), 29 deletions(-)

diff --git a/CHANGES.txt b/CHANGES.txt
index 1115aab..95b6144 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,5 +1,10 @@
 All tickets are children of http://trac.gispython.org/lab/ticket.
 
+1.2.3 (2010-08-17)
+------------------
+- Add mapping function.
+- Fix problem with GEOSisValidReason symbol for GEOS < 3.1.
+
 1.2.2 (2010-07-23)
 ------------------
 - Add representative_point method.
diff --git a/PKG-INFO b/PKG-INFO
index 25d9b53..d1567fe 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,6 +1,6 @@
 Metadata-Version: 1.0
 Name: Shapely
-Version: 1.2.2
+Version: 1.2.3
 Summary: Geometric objects, predicates, and operations
 Home-page: http://trac.gispython.org/lab/wiki/Shapely
 Author: Sean Gillies
diff --git a/Shapely.egg-info/PKG-INFO b/Shapely.egg-info/PKG-INFO
index 25d9b53..d1567fe 100644
--- a/Shapely.egg-info/PKG-INFO
+++ b/Shapely.egg-info/PKG-INFO
@@ -1,6 +1,6 @@
 Metadata-Version: 1.0
 Name: Shapely
-Version: 1.2.2
+Version: 1.2.3
 Summary: Geometric objects, predicates, and operations
 Home-page: http://trac.gispython.org/lab/wiki/Shapely
 Author: Sean Gillies
diff --git a/Shapely.egg-info/SOURCES.txt b/Shapely.egg-info/SOURCES.txt
index a6b5418..8674cb8 100644
--- a/Shapely.egg-info/SOURCES.txt
+++ b/Shapely.egg-info/SOURCES.txt
@@ -64,6 +64,7 @@ shapely/tests/test_doctests.py
 shapely/tests/test_emptiness.py
 shapely/tests/test_equality.py
 shapely/tests/test_geomseq.py
+shapely/tests/test_mapping.py
 shapely/tests/test_prepared.py
 shapely/tests/test_singularity.py
 shapely/tests/test_validation.py
diff --git a/docs/_build/html/_sources/manual.txt 
b/docs/_build/html/_sources/manual.txt
index 4ebd883..dd6ee8d 100644
--- a/docs/_build/html/_sources/manual.txt
+++ b/docs/_build/html/_sources/manual.txt
@@ -3,8 +3,8 @@ The Shapely 1.2 User Manual (Preview)
 =====================================
 
 :Author: Sean Gillies, <sean.gill...@gmail.com>
-:Revision: 1.2.1
-:Date: 13 July 2010
+:Revision: 1.2.2
+:Date: 10 August 2010
 :Copyright: 
   This work is licensed under a `Creative Commons Attribution 3.0
   United States License`__.
@@ -214,7 +214,7 @@ General Attributes and Methods
   geometric object.
 
 .. note::
-  This is not in the general the same as the centroid.
+  This is not in general the same as the centroid.
 
 .. sourcecode:: pycon
 
@@ -224,11 +224,6 @@ General Attributes and Methods
   >>> donut.representative_point().wkt
   'POINT (-1.5000000000000000 0.0000000000000000)'
 
-.. sourcecode:: pycon
-
-  >>> Point(0,0).distance(Point(1,1))
-  1.4142135623730951
-
 .. _points:
 
 Points
@@ -1387,8 +1382,8 @@ Figure 1. Convex hull (blue) of 2 points (left) and of 6 
points (right).
 
 .. attribute:: object.envelope
 
-  Returns a representation of the point or smallest rectangular polygon that
-  contains the object.
+  Returns a representation of the point or smallest rectangular polygon (with
+  sides parallel to the coordinate axes) that contains the object.
 
 .. sourcecode:: pycon
 
@@ -1714,6 +1709,26 @@ Or a simple placemark-type object:
   >>> list(shape.coords)
   [(0.0, 0.0)]
 
+The GeoJSON-like mapping of a geometric object can be obtained using
+:func:`shapely.geometry.mapping`.
+
+.. function:: shapely.geometry.mapping(ob)
+
+   Return a new, independent geometry with coordinates `copied` from the
+   context.
+
+For example, using the same `GeoThing` class:
+
+.. sourcecode:: pycon
+
+  >>> from shapely.geometry import mapping
+  >>> thing = GeoThing({"type": "Point", "coordinates": (0.0, 0.0)})
+  >>> m = mapping(thing)
+  >>> m['type']
+  'Point'
+  >>> m['coordinates']
+  (0.0, 0.0)}
+
 Conclusion
 ==========
 
diff --git a/docs/manual.txt b/docs/manual.txt
index 350acc0..dd6ee8d 100644
--- a/docs/manual.txt
+++ b/docs/manual.txt
@@ -3,8 +3,8 @@ The Shapely 1.2 User Manual (Preview)
 =====================================
 
 :Author: Sean Gillies, <sean.gill...@gmail.com>
-:Revision: 1.2.1
-:Date: 13 July 2010
+:Revision: 1.2.2
+:Date: 10 August 2010
 :Copyright: 
   This work is licensed under a `Creative Commons Attribution 3.0
   United States License`__.
@@ -214,7 +214,7 @@ General Attributes and Methods
   geometric object.
 
 .. note::
-  This is not in the general the same as the centroid.
+  This is not in general the same as the centroid.
 
 .. sourcecode:: pycon
 
@@ -1382,8 +1382,8 @@ Figure 1. Convex hull (blue) of 2 points (left) and of 6 
points (right).
 
 .. attribute:: object.envelope
 
-  Returns a representation of the point or smallest rectangular polygon that
-  contains the object.
+  Returns a representation of the point or smallest rectangular polygon (with
+  sides parallel to the coordinate axes) that contains the object.
 
 .. sourcecode:: pycon
 
@@ -1709,6 +1709,26 @@ Or a simple placemark-type object:
   >>> list(shape.coords)
   [(0.0, 0.0)]
 
+The GeoJSON-like mapping of a geometric object can be obtained using
+:func:`shapely.geometry.mapping`.
+
+.. function:: shapely.geometry.mapping(ob)
+
+   Return a new, independent geometry with coordinates `copied` from the
+   context.
+
+For example, using the same `GeoThing` class:
+
+.. sourcecode:: pycon
+
+  >>> from shapely.geometry import mapping
+  >>> thing = GeoThing({"type": "Point", "coordinates": (0.0, 0.0)})
+  >>> m = mapping(thing)
+  >>> m['type']
+  'Point'
+  >>> m['coordinates']
+  (0.0, 0.0)}
+
 Conclusion
 ==========
 
diff --git a/setup.py b/setup.py
index 6b0cc65..00ad9b1 100644
--- a/setup.py
+++ b/setup.py
@@ -16,7 +16,7 @@ readme_text = file('README.txt', 'rb').read()
 setup_args = dict(
     metadata_version    = '1.2',
     name                = 'Shapely',
-    version             = '1.2.2',
+    version             = '1.2.3',
     requires_python     = '>=2.5,<3',
     requires_external   = 'libgeos_c (>=3.1)', 
     description         = 'Geometric objects, predicates, and operations',
diff --git a/shapely/ctypes_declarations.py b/shapely/ctypes_declarations.py
index 6d1971c..1dc705b 100644
--- a/shapely/ctypes_declarations.py
+++ b/shapely/ctypes_declarations.py
@@ -167,9 +167,6 @@ def prototype(lgeos, geosVersion):
     lgeos.GEOSisValid.restype = ctypes.c_byte
     lgeos.GEOSisValid.argtypes = [ctypes.c_void_p]
 
-    lgeos.GEOSisValidReason.restype = allocated_c_char_p
-    lgeos.GEOSisValidReason.argtypes = [ctypes.c_void_p]
-
     lgeos.GEOSisSimple.restype = ctypes.c_byte
     lgeos.GEOSisSimple.argtypes = [ctypes.c_void_p]
 
@@ -249,6 +246,9 @@ def prototype(lgeos, geosVersion):
         lgeos.GEOSPreparedCovers.restype = ctypes.c_int
         lgeos.GEOSPreparedCovers.argtypes = [ctypes.c_void_p, ctypes.c_void_p]
 
+        lgeos.GEOSisValidReason.restype = allocated_c_char_p
+        lgeos.GEOSisValidReason.argtypes = [ctypes.c_void_p]
+
     # Other, GEOS C API 1.5.0+
     if geosVersion >= (1, 5, 0):
         lgeos.GEOSUnionCascaded.restype = ctypes.c_void_p
diff --git a/shapely/geometry/__init__.py b/shapely/geometry/__init__.py
index f39e02b..4e1a1a9 100644
--- a/shapely/geometry/__init__.py
+++ b/shapely/geometry/__init__.py
@@ -1,7 +1,7 @@
 """Geometry classes and factories
 """
 
-from geo import shape, asShape
+from geo import shape, asShape, mapping
 from point import Point, asPoint
 from linestring import LineString, asLineString
 from polygon import Polygon, asPolygon
@@ -14,7 +14,7 @@ __all__ = [
     'shape', 'asShape', 'Point', 'asPoint', 'LineString', 'asLineString',
     'Polygon', 'asPolygon', 'MultiPoint', 'asMultiPoint',
     'MultiLineString', 'asMultiLineString', 'MultiPolygon', 'asMultiPolygon',
-    'GeometryCollection'
+    'GeometryCollection', 'mapping'
     ]
 
 
diff --git a/shapely/geometry/base.py b/shapely/geometry/base.py
index bffa6dc..ee1db9f 100644
--- a/shapely/geometry/base.py
+++ b/shapely/geometry/base.py
@@ -94,10 +94,14 @@ class BaseGeometry(object):
     def _is_empty(self):
         return self.__geom__ in [EMPTY, None]
 
+    # a reference to the so/dll proxy to preserve access during clean up
+    _lgeos = lgeos
+
     def empty(self):
+        # TODO: defer cleanup to the implementation. We shouldn't be
+        # explicitly calling a lgeos method here.
         if not (self._owned or self._is_empty):
-            from shapely.geos import lgeos
-            lgeos.GEOSGeom_destroy(self.__geom__)
+            self._lgeos.GEOSGeom_destroy(self.__geom__)
         self.__geom__ = EMPTY
 
     def __del__(self):
@@ -574,7 +578,6 @@ class HeterogeneousGeometrySequence(GeometrySequence):
         g._owned = True
         return g
 
-
 # Test runner
 def _test():
     import doctest
diff --git a/shapely/geometry/geo.py b/shapely/geometry/geo.py
index 5c78d0c..ebdc9ac 100644
--- a/shapely/geometry/geo.py
+++ b/shapely/geometry/geo.py
@@ -62,3 +62,7 @@ def asShape(context):
         return MultiPolygonAdapter(ob["coordinates"], context_type='geojson')
     else:
         raise ValueError("Unknown geometry type: %s" % geom_type)
+
+def mapping(ob):
+    """Returns a GeoJSON-like mapping"""
+    return ob.__geo_interface__
diff --git a/shapely/geos.py b/shapely/geos.py
index 0f80ced..4dfe04f 100644
--- a/shapely/geos.py
+++ b/shapely/geos.py
@@ -298,6 +298,8 @@ class LGEOS15(LGEOSBase):
               ):
             pred.func.errcheck = errcheck_predicate
 
+        self.GEOSisValidReason.func.errcheck = errcheck_just_free
+        
         self.methods['area'] = self.GEOSArea
         self.methods['boundary'] = self.GEOSBoundary
         self.methods['buffer'] = self.GEOSBuffer
@@ -351,8 +353,6 @@ class LGEOS16LR(LGEOS16):
     def __init__(self, dll):
         super(LGEOS16LR, self).__init__(dll)
 
-        self.GEOSisValidReason.func.errcheck = errcheck_just_free
-        
         self.methods['project'] = self.GEOSProject
         self.methods['project_normalized'] = self.GEOSProjectNormalized
         self.methods['interpolate'] = self.GEOSInterpolate
diff --git a/shapely/tests/__init__.py b/shapely/tests/__init__.py
index 5f68983..30f2347 100644
--- a/shapely/tests/__init__.py
+++ b/shapely/tests/__init__.py
@@ -2,6 +2,7 @@ from unittest import TestSuite
 
 import test_doctests, test_prepared, test_equality, test_geomseq, test_xy
 import test_collection, test_emptiness, test_singularity, test_validation
+import test_mapping
 
 def test_suite():
     suite = TestSuite()
@@ -14,5 +15,6 @@ def test_suite():
     suite.addTest(test_collection.test_suite())
     suite.addTest(test_singularity.test_suite())
     suite.addTest(test_validation.test_suite())
+    suite.addTest(test_mapping.test_suite())
     return suite
 
diff --git a/shapely/tests/test_mapping.py b/shapely/tests/test_mapping.py
new file mode 100644
index 0000000..e21b407
--- /dev/null
+++ b/shapely/tests/test_mapping.py
@@ -0,0 +1,11 @@
+import unittest
+from shapely.geometry import Point, mapping
+
+class MappingTestCase(unittest.TestCase):
+    def test_point(self):
+        m = mapping(Point(0, 0))
+        self.failUnlessEqual(m['type'], 'Point')
+        self.failUnlessEqual(m['coordinates'], (0.0, 0.0))
+
+def test_suite():
+    return unittest.TestLoader().loadTestsFromTestCase(MappingTestCase)
diff --git a/shapely/validation.py b/shapely/validation.py
index 69dde86..cd390d2 100644
--- a/shapely/validation.py
+++ b/shapely/validation.py
@@ -1,4 +1,4 @@
-#
+# TODO: allow for implementations using other than GEOS
 
 from shapely.geos import lgeos
 

-- 
Alioth's /usr/local/bin/git-commit-notice on 
/srv/git.debian.org/git/pkg-grass/python-shapely.git

_______________________________________________
Pkg-grass-devel mailing list
Pkg-grass-devel@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-grass-devel

Reply via email to