shapely 1.2.7__py2.5-win32.egg → 1.2.8__py2.5-win32.egg

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
EGG-INFO/PKG-INFO CHANGED
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 1.0
2
2
  Name: Shapely
3
- Version: 1.2.7
3
+ Version: 1.2.8
4
4
  Summary: Geometric objects, predicates, and operations
5
5
  Home-page: http://trac.gispython.org/lab/wiki/Shapely
6
6
  Author: Sean Gillies
@@ -259,6 +259,9 @@ def prototype(lgeos, geosVersion):
259
259
  # Linear referencing features aren't found in versions 1.5,
260
260
  # but not in all libs versioned 1.6.0 either!
261
261
  if hasattr(lgeos, 'GEOSProject'):
262
+ lgeos.GEOSSingleSidedBuffer.restype = ctypes.c_void_p
263
+ lgeos.GEOSSingleSidedBuffer.argtypes = [ctypes.c_void_p, ctypes.c_double, ctypes.c_int, ctypes.c_int, ctypes.c_double, ctypes.c_int]
264
+
262
265
  lgeos.GEOSProject.restype = ctypes.c_double
263
266
  lgeos.GEOSProject.argtypes = [ctypes.c_void_p, ctypes.c_void_p]
264
267
 
Binary file
shapely/ftools.py ADDED
@@ -0,0 +1,78 @@
1
+ # Backport some of functools from Python 2.5 standard library for Shapely
2
+ # on Python 2.4
3
+ #
4
+ # Python module wrapper for _functools C module
5
+ # to allow utilities written in Python to be added
6
+ # to the functools module.
7
+ # Written by Nick Coghlan <ncoghlan at gmail.com>
8
+ # Copyright (C) 2006 Python Software Foundation.
9
+ # See C source code for _functools credits/copyright
10
+ #
11
+ # _functools module written and maintained
12
+ # by Hye-Shik Chang <perky@FreeBSD.org>
13
+ # with adaptations by Raymond Hettinger <python@rcn.com>
14
+ # Copyright (c) 2004, 2005, 2006 Python Software Foundation.
15
+ # All rights reserved.
16
+
17
+ def _partial(func, *args, **keywords):
18
+ def newfunc(*fargs, **fkeywords):
19
+ newkeywords = keywords.copy()
20
+ newkeywords.update(fkeywords)
21
+ return func(
22
+ *(args + fargs), **newkeywords)
23
+ newfunc.func = func
24
+ newfunc.args = args
25
+ newfunc.keywords = keywords
26
+ return newfunc
27
+
28
+ # update_wrapper() and wraps() are tools to help write
29
+ # wrapper functions that can handle naive introspection
30
+
31
+ WRAPPER_ASSIGNMENTS = ('__module__', '__name__', '__doc__')
32
+ WRAPPER_UPDATES = ('__dict__',)
33
+ def _update_wrapper(wrapper,
34
+ wrapped,
35
+ assigned = WRAPPER_ASSIGNMENTS,
36
+ updated = WRAPPER_UPDATES):
37
+ """Update a wrapper function to look like the wrapped function
38
+
39
+ wrapper is the function to be updated
40
+ wrapped is the original function
41
+ assigned is a tuple naming the attributes assigned directly
42
+ from the wrapped function to the wrapper function (defaults to
43
+ functools.WRAPPER_ASSIGNMENTS)
44
+ updated is a tuple naming the attributes of the wrapper that
45
+ are updated with the corresponding attribute from the wrapped
46
+ function (defaults to functools.WRAPPER_UPDATES)
47
+ """
48
+ for attr in assigned:
49
+ setattr(wrapper, attr, getattr(wrapped, attr))
50
+ for attr in updated:
51
+ getattr(wrapper, attr).update(getattr(wrapped, attr, {}))
52
+ # Return the wrapper so this can be used as a decorator via partial()
53
+ return wrapper
54
+
55
+ def _wraps(wrapped,
56
+ assigned = WRAPPER_ASSIGNMENTS,
57
+ updated = WRAPPER_UPDATES):
58
+ """Decorator factory to apply update_wrapper() to a wrapper function
59
+
60
+ Returns a decorator that invokes update_wrapper() with the decorated
61
+ function as the wrapper argument and the arguments to wraps() as the
62
+ remaining arguments. Default arguments are as for update_wrapper().
63
+ This is a convenience function to simplify applying partial() to
64
+ update_wrapper().
65
+ """
66
+ return _partial(_update_wrapper, wrapped=wrapped,
67
+ assigned=assigned, updated=updated)
68
+
69
+ # Use stdlib's functools if available
70
+ try:
71
+ from functools import partial, update_wrapper, wraps
72
+ have_functools = 1
73
+ except ImportError:
74
+ partial = _partial
75
+ update_wrapper = _update_wrapper
76
+ wraps = _wraps
77
+ have_functools = 0
78
+
shapely/ftools.pyc ADDED
Binary file
shapely/geometry/base.py CHANGED
@@ -1,11 +1,11 @@
1
1
  """Base geometry class and utilities
2
2
  """
3
3
 
4
- from functools import wraps
5
4
  import sys
6
5
  import warnings
7
6
 
8
7
  from shapely.coords import CoordinateSequence
8
+ from shapely.ftools import wraps
9
9
  from shapely.geos import lgeos
10
10
  from shapely.impl import DefaultImplementation, delegated
11
11
  from shapely import wkb, wkt
shapely/geometry/base.pyc CHANGED
Binary file
@@ -4,8 +4,8 @@
4
4
  from ctypes import c_double, cast, POINTER
5
5
  from ctypes import ArgumentError
6
6
 
7
- from shapely.geos import lgeos
8
- from shapely.geometry.base import BaseGeometry
7
+ from shapely.geos import lgeos, TopologicalError
8
+ from shapely.geometry.base import BaseGeometry, geom_factory
9
9
  from shapely.geometry.proxy import CachingGeometryProxy
10
10
 
11
11
  __all__ = ['LineString', 'asLineString']
@@ -79,6 +79,35 @@ class LineString(BaseGeometry):
79
79
  [0.0, 1.0]
80
80
  """
81
81
  return self.coords.xy
82
+
83
+ def parallel_offset(
84
+ self, distance, side,
85
+ resolution=16, join_style=1, mitre_limit=1.0):
86
+
87
+ """Returns a LineString or MultiLineString geometry at a distance from
88
+ the object on its right or its left side.
89
+
90
+ Distance must be a positive float value. The side parameter may be
91
+ 'left' or 'right'. The resolution of the buffer around each vertex of
92
+ the object increases by increasing the resolution keyword parameter or
93
+ third positional parameter.
94
+
95
+ The join style is for outside corners between line segments. Accepted
96
+ values are 1 => ROUND, 2 => MITRE, 3 => BEVEL.
97
+
98
+ The mitre ratio limit is used for very sharp corners. It is the ratio
99
+ of the distance from the corner to the end of the mitred offset corner.
100
+ When two line segments meet at a sharp angle, a miter join will extend
101
+ far beyond the original geometry. To prevent unreasonable geometry, the
102
+ mitre limit allows controlling the maximum length of the join corner.
103
+ Corners with a ratio which exceed the limit will be beveled."""
104
+
105
+ try:
106
+ return geom_factory(self.impl['parallel_offset'](
107
+ self, distance, resolution, join_style, mitre_limit,
108
+ bool(side=='left')))
109
+ except WindowsError:
110
+ raise TopologicalError()
82
111
 
83
112
 
84
113
  class LineStringAdapter(CachingGeometryProxy, LineString):
Binary file
shapely/geos.py CHANGED
@@ -3,7 +3,6 @@ Proxies for the libgeos_c shared lib, GEOS-specific exceptions, and utilities
3
3
  """
4
4
 
5
5
  import atexit
6
- import functools
7
6
  import logging
8
7
  import os
9
8
  import sys
@@ -13,8 +12,11 @@ import ctypes
13
12
  from ctypes import cdll, CDLL, PyDLL, CFUNCTYPE, c_char_p, c_void_p, string_at
14
13
  from ctypes.util import find_library
15
14
 
15
+ import ftools
16
16
  from ctypes_declarations import prototype
17
17
 
18
+
19
+
18
20
  # Begin by creating a do-nothing handler and adding to this module's logger.
19
21
  class NullHandler(logging.Handler):
20
22
  def emit(self, record):
@@ -267,7 +269,7 @@ class LGEOS15(LGEOSBase):
267
269
  for key in filter(lambda x: not x.endswith('_r'), keys):
268
270
  if key + '_r' in keys:
269
271
  reentr_func = getattr(self._lgeos, key + '_r')
270
- attr = functools.partial(reentr_func, self.geos_handle)
272
+ attr = ftools.partial(reentr_func, self.geos_handle)
271
273
  attr.__name__ = reentr_func.__name__
272
274
  setattr(self, key, attr)
273
275
  else:
@@ -349,6 +351,7 @@ class LGEOS16LR(LGEOS16):
349
351
  def __init__(self, dll):
350
352
  super(LGEOS16LR, self).__init__(dll)
351
353
 
354
+ self.methods['parallel_offset'] = self.GEOSSingleSidedBuffer
352
355
  self.methods['project'] = self.GEOSProject
353
356
  self.methods['project_normalized'] = self.GEOSProjectNormalized
354
357
  self.methods['interpolate'] = self.GEOSInterpolate
shapely/geos.pyc CHANGED
Binary file
shapely/impl.py CHANGED
@@ -11,7 +11,7 @@ This is layer number 2 from the list below.
11
11
  Shapely 1.2 includes a GEOS backend and it is the default.
12
12
  """
13
13
 
14
- from functools import wraps
14
+ from ftools import wraps
15
15
 
16
16
  from shapely.coords import BoundsOp
17
17
  from shapely.geos import lgeos
@@ -98,7 +98,8 @@ IMPL16 = {
98
98
  }
99
99
 
100
100
  IMPL16LR = {
101
- 'project_normalized': (ProjectOp, 'project_normalized'),
101
+ 'parallel_offset': (UnaryTopologicalOp, 'parallel_offset'),
102
+ 'project_normalized': (ProjectOp, 'project_normalized'),
102
103
  'project': (ProjectOp, 'project'),
103
104
  'interpolate_normalized': (InterpolateOp, 'interpolate_normalized'),
104
105
  'interpolate': (InterpolateOp, 'interpolate'),
shapely/impl.pyc CHANGED
Binary file