Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
D
django
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
django
Commits
b6951538
Kaydet (Commit)
b6951538
authored
Nis 24, 2015
tarafından
Claude Paroz
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Rearranged imports in geos files
üst
d9bcba9b
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
58 additions
and
57 deletions
+58
-57
collections.py
django/contrib/gis/geos/collections.py
+4
-2
geometry.py
django/contrib/gis/geos/geometry.py
+44
-52
libgeos.py
django/contrib/gis/geos/libgeos.py
+3
-0
linestring.py
django/contrib/gis/geos/linestring.py
+5
-2
point.py
django/contrib/gis/geos/point.py
+1
-0
prepared.py
django/contrib/gis/geos/prepared.py
+1
-1
No files found.
django/contrib/gis/geos/collections.py
Dosyayı görüntüle @
b6951538
...
@@ -5,7 +5,9 @@
...
@@ -5,7 +5,9 @@
from
ctypes
import
byref
,
c_int
,
c_uint
from
ctypes
import
byref
,
c_int
,
c_uint
from
django.contrib.gis.geos
import
prototypes
as
capi
from
django.contrib.gis.geos
import
prototypes
as
capi
from
django.contrib.gis.geos.geometry
import
GEOSGeometry
from
django.contrib.gis.geos.geometry
import
(
GEOSGeometry
,
ProjectInterpolateMixin
,
)
from
django.contrib.gis.geos.libgeos
import
get_pointer_arr
from
django.contrib.gis.geos.libgeos
import
get_pointer_arr
from
django.contrib.gis.geos.linestring
import
LinearRing
,
LineString
from
django.contrib.gis.geos.linestring
import
LinearRing
,
LineString
from
django.contrib.gis.geos.point
import
Point
from
django.contrib.gis.geos.point
import
Point
...
@@ -99,7 +101,7 @@ class MultiPoint(GeometryCollection):
...
@@ -99,7 +101,7 @@ class MultiPoint(GeometryCollection):
_typeid
=
4
_typeid
=
4
class
MultiLineString
(
GeometryCollection
):
class
MultiLineString
(
ProjectInterpolateMixin
,
GeometryCollection
):
_allowed
=
(
LineString
,
LinearRing
)
_allowed
=
(
LineString
,
LinearRing
)
_typeid
=
5
_typeid
=
5
...
...
django/contrib/gis/geos/geometry.py
Dosyayı görüntüle @
b6951538
...
@@ -14,6 +14,7 @@ from django.contrib.gis.geos.coordseq import GEOSCoordSeq
...
@@ -14,6 +14,7 @@ from django.contrib.gis.geos.coordseq import GEOSCoordSeq
from
django.contrib.gis.geos.error
import
GEOSException
,
GEOSIndexError
from
django.contrib.gis.geos.error
import
GEOSException
,
GEOSIndexError
from
django.contrib.gis.geos.libgeos
import
GEOM_PTR
from
django.contrib.gis.geos.libgeos
import
GEOM_PTR
from
django.contrib.gis.geos.mutable_list
import
ListMixin
from
django.contrib.gis.geos.mutable_list
import
ListMixin
from
django.contrib.gis.geos.prepared
import
PreparedGeometry
from
django.contrib.gis.geos.prototypes.io
import
(
from
django.contrib.gis.geos.prototypes.io
import
(
ewkb_w
,
wkb_r
,
wkb_w
,
wkt_r
,
wkt_w
,
ewkb_w
,
wkb_r
,
wkb_w
,
wkt_r
,
wkt_w
,
)
)
...
@@ -27,8 +28,10 @@ class GEOSGeometry(GEOSBase, ListMixin):
...
@@ -27,8 +28,10 @@ class GEOSGeometry(GEOSBase, ListMixin):
# Raise GEOSIndexError instead of plain IndexError
# Raise GEOSIndexError instead of plain IndexError
# (see ticket #4740 and GEOSIndexError docstring)
# (see ticket #4740 and GEOSIndexError docstring)
_IndexError
=
GEOSIndexError
_IndexError
=
GEOSIndexError
_GEOS_CLASSES
=
None
ptr_type
=
GEOM_PTR
ptr_type
=
GEOM_PTR
has_cs
=
False
# Only Point, LineString, LinearRing have coordinate sequences
def
__init__
(
self
,
geo_input
,
srid
=
None
):
def
__init__
(
self
,
geo_input
,
srid
=
None
):
"""
"""
...
@@ -92,7 +95,24 @@ class GEOSGeometry(GEOSBase, ListMixin):
...
@@ -92,7 +95,24 @@ class GEOSGeometry(GEOSBase, ListMixin):
self
.
srid
=
srid
self
.
srid
=
srid
# Setting the class type (e.g., Point, Polygon, etc.)
# Setting the class type (e.g., Point, Polygon, etc.)
self
.
__class__
=
GEOS_CLASSES
[
self
.
geom_typeid
]
if
GEOSGeometry
.
_GEOS_CLASSES
is
None
:
# Lazy-loaded variable to avoid import conflicts with GEOSGeometry.
from
.linestring
import
LineString
,
LinearRing
from
.point
import
Point
from
.polygon
import
Polygon
from
.collections
import
(
GeometryCollection
,
MultiPoint
,
MultiLineString
,
MultiPolygon
)
GEOSGeometry
.
_GEOS_CLASSES
=
{
0
:
Point
,
1
:
LineString
,
2
:
LinearRing
,
3
:
Polygon
,
4
:
MultiPoint
,
5
:
MultiLineString
,
6
:
MultiPolygon
,
7
:
GeometryCollection
,
}
self
.
__class__
=
GEOSGeometry
.
_GEOS_CLASSES
[
self
.
geom_typeid
]
# Setting the coordinate sequence for the geometry (will be None on
# Setting the coordinate sequence for the geometry (will be None on
# geometries that do not have coordinate sequences)
# geometries that do not have coordinate sequences)
...
@@ -185,15 +205,6 @@ class GEOSGeometry(GEOSBase, ListMixin):
...
@@ -185,15 +205,6 @@ class GEOSGeometry(GEOSBase, ListMixin):
return
self
.
sym_difference
(
other
)
return
self
.
sym_difference
(
other
)
# #### Coordinate Sequence Routines ####
# #### Coordinate Sequence Routines ####
@property
def
has_cs
(
self
):
"Returns True if this Geometry has a coordinate sequence, False if not."
# Only these geometries are allowed to have coordinate sequences.
if
isinstance
(
self
,
(
Point
,
LineString
,
LinearRing
)):
return
True
else
:
return
False
def
_set_cs
(
self
):
def
_set_cs
(
self
):
"Sets the coordinate sequence for this Geometry."
"Sets the coordinate sequence for this Geometry."
if
self
.
has_cs
:
if
self
.
has_cs
:
...
@@ -560,16 +571,6 @@ class GEOSGeometry(GEOSBase, ListMixin):
...
@@ -560,16 +571,6 @@ class GEOSGeometry(GEOSBase, ListMixin):
"Return the envelope for this geometry (a polygon)."
"Return the envelope for this geometry (a polygon)."
return
self
.
_topology
(
capi
.
geos_envelope
(
self
.
ptr
))
return
self
.
_topology
(
capi
.
geos_envelope
(
self
.
ptr
))
def
interpolate
(
self
,
distance
):
if
not
isinstance
(
self
,
(
LineString
,
MultiLineString
)):
raise
TypeError
(
'interpolate only works on LineString and MultiLineString geometries'
)
return
self
.
_topology
(
capi
.
geos_interpolate
(
self
.
ptr
,
distance
))
def
interpolate_normalized
(
self
,
distance
):
if
not
isinstance
(
self
,
(
LineString
,
MultiLineString
)):
raise
TypeError
(
'interpolate only works on LineString and MultiLineString geometries'
)
return
self
.
_topology
(
capi
.
geos_interpolate_normalized
(
self
.
ptr
,
distance
))
def
intersection
(
self
,
other
):
def
intersection
(
self
,
other
):
"Returns a Geometry representing the points shared by this Geometry and other."
"Returns a Geometry representing the points shared by this Geometry and other."
return
self
.
_topology
(
capi
.
geos_intersection
(
self
.
ptr
,
other
.
ptr
))
return
self
.
_topology
(
capi
.
geos_intersection
(
self
.
ptr
,
other
.
ptr
))
...
@@ -579,20 +580,6 @@ class GEOSGeometry(GEOSBase, ListMixin):
...
@@ -579,20 +580,6 @@ class GEOSGeometry(GEOSBase, ListMixin):
"Computes an interior point of this Geometry."
"Computes an interior point of this Geometry."
return
self
.
_topology
(
capi
.
geos_pointonsurface
(
self
.
ptr
))
return
self
.
_topology
(
capi
.
geos_pointonsurface
(
self
.
ptr
))
def
project
(
self
,
point
):
if
not
isinstance
(
point
,
Point
):
raise
TypeError
(
'locate_point argument must be a Point'
)
if
not
isinstance
(
self
,
(
LineString
,
MultiLineString
)):
raise
TypeError
(
'locate_point only works on LineString and MultiLineString geometries'
)
return
capi
.
geos_project
(
self
.
ptr
,
point
.
ptr
)
def
project_normalized
(
self
,
point
):
if
not
isinstance
(
point
,
Point
):
raise
TypeError
(
'locate_point argument must be a Point'
)
if
not
isinstance
(
self
,
(
LineString
,
MultiLineString
)):
raise
TypeError
(
'locate_point only works on LineString and MultiLineString geometries'
)
return
capi
.
geos_project_normalized
(
self
.
ptr
,
point
.
ptr
)
def
relate
(
self
,
other
):
def
relate
(
self
,
other
):
"Returns the DE-9IM intersection matrix for this Geometry and the other."
"Returns the DE-9IM intersection matrix for this Geometry and the other."
return
capi
.
geos_relate
(
self
.
ptr
,
other
.
ptr
)
.
decode
()
return
capi
.
geos_relate
(
self
.
ptr
,
other
.
ptr
)
.
decode
()
...
@@ -647,6 +634,7 @@ class GEOSGeometry(GEOSBase, ListMixin):
...
@@ -647,6 +634,7 @@ class GEOSGeometry(GEOSBase, ListMixin):
Returns the extent of this geometry as a 4-tuple, consisting of
Returns the extent of this geometry as a 4-tuple, consisting of
(xmin, ymin, xmax, ymax).
(xmin, ymin, xmax, ymax).
"""
"""
from
.point
import
Point
env
=
self
.
envelope
env
=
self
.
envelope
if
isinstance
(
env
,
Point
):
if
isinstance
(
env
,
Point
):
xmin
,
ymin
=
env
.
tuple
xmin
,
ymin
=
env
.
tuple
...
@@ -668,21 +656,25 @@ class GEOSGeometry(GEOSBase, ListMixin):
...
@@ -668,21 +656,25 @@ class GEOSGeometry(GEOSBase, ListMixin):
"Clones this Geometry."
"Clones this Geometry."
return
GEOSGeometry
(
capi
.
geom_clone
(
self
.
ptr
),
srid
=
self
.
srid
)
return
GEOSGeometry
(
capi
.
geom_clone
(
self
.
ptr
),
srid
=
self
.
srid
)
# Class mapping dictionary. Has to be at the end to avoid import
# conflicts with GEOSGeometry.
class
ProjectInterpolateMixin
(
object
):
from
django.contrib.gis.geos.linestring
import
LineString
,
LinearRing
# isort:skip
"""
from
django.contrib.gis.geos.point
import
Point
# isort:skip
Used for LineString and MultiLineString.
from
django.contrib.gis.geos.polygon
import
Polygon
# isort:skip
"""
from
django.contrib.gis.geos.collections
import
(
# isort:skip
def
interpolate
(
self
,
distance
):
GeometryCollection
,
MultiPoint
,
MultiLineString
,
MultiPolygon
)
return
self
.
_topology
(
capi
.
geos_interpolate
(
self
.
ptr
,
distance
))
from
django.contrib.gis.geos.prepared
import
PreparedGeometry
# isort:skip
GEOS_CLASSES
=
{
def
interpolate_normalized
(
self
,
distance
):
0
:
Point
,
return
self
.
_topology
(
capi
.
geos_interpolate_normalized
(
self
.
ptr
,
distance
))
1
:
LineString
,
2
:
LinearRing
,
def
project
(
self
,
point
):
3
:
Polygon
,
from
.point
import
Point
4
:
MultiPoint
,
if
not
isinstance
(
point
,
Point
):
5
:
MultiLineString
,
raise
TypeError
(
'locate_point argument must be a Point'
)
6
:
MultiPolygon
,
return
capi
.
geos_project
(
self
.
ptr
,
point
.
ptr
)
7
:
GeometryCollection
,
}
def
project_normalized
(
self
,
point
):
from
.point
import
Point
if
not
isinstance
(
point
,
Point
):
raise
TypeError
(
'locate_point argument must be a Point'
)
return
capi
.
geos_project_normalized
(
self
.
ptr
,
point
.
ptr
)
django/contrib/gis/geos/libgeos.py
Dosyayı görüntüle @
b6951538
...
@@ -135,6 +135,9 @@ lgeos = SimpleLazyObject(load_geos)
...
@@ -135,6 +135,9 @@ lgeos = SimpleLazyObject(load_geos)
class
GEOSFuncFactory
(
object
):
class
GEOSFuncFactory
(
object
):
"""
Lazy loading of GEOS functions.
"""
argtypes
=
None
argtypes
=
None
restype
=
None
restype
=
None
errcheck
=
None
errcheck
=
None
...
...
django/contrib/gis/geos/linestring.py
Dosyayı görüntüle @
b6951538
from
django.contrib.gis.geos
import
prototypes
as
capi
from
django.contrib.gis.geos
import
prototypes
as
capi
from
django.contrib.gis.geos.coordseq
import
GEOSCoordSeq
from
django.contrib.gis.geos.coordseq
import
GEOSCoordSeq
from
django.contrib.gis.geos.error
import
GEOSException
from
django.contrib.gis.geos.error
import
GEOSException
from
django.contrib.gis.geos.geometry
import
GEOSGeometry
from
django.contrib.gis.geos.geometry
import
(
GEOSGeometry
,
ProjectInterpolateMixin
,
)
from
django.contrib.gis.geos.point
import
Point
from
django.contrib.gis.geos.point
import
Point
from
django.contrib.gis.shortcuts
import
numpy
from
django.contrib.gis.shortcuts
import
numpy
from
django.utils.six.moves
import
range
from
django.utils.six.moves
import
range
class
LineString
(
GEOSGeometry
):
class
LineString
(
ProjectInterpolateMixin
,
GEOSGeometry
):
_init_func
=
capi
.
create_linestring
_init_func
=
capi
.
create_linestring
_minlength
=
2
_minlength
=
2
has_cs
=
True
def
__init__
(
self
,
*
args
,
**
kwargs
):
def
__init__
(
self
,
*
args
,
**
kwargs
):
"""
"""
...
...
django/contrib/gis/geos/point.py
Dosyayı görüntüle @
b6951538
...
@@ -10,6 +10,7 @@ from django.utils.six.moves import range
...
@@ -10,6 +10,7 @@ from django.utils.six.moves import range
class
Point
(
GEOSGeometry
):
class
Point
(
GEOSGeometry
):
_minlength
=
2
_minlength
=
2
_maxlength
=
3
_maxlength
=
3
has_cs
=
True
def
__init__
(
self
,
x
,
y
=
None
,
z
=
None
,
srid
=
None
):
def
__init__
(
self
,
x
,
y
=
None
,
z
=
None
,
srid
=
None
):
"""
"""
...
...
django/contrib/gis/geos/prepared.py
Dosyayı görüntüle @
b6951538
from
.base
import
GEOSBase
from
.base
import
GEOSBase
from
.error
import
GEOSException
from
.error
import
GEOSException
from
.geometry
import
GEOSGeometry
from
.libgeos
import
geos_version_info
from
.libgeos
import
geos_version_info
from
.prototypes
import
prepared
as
capi
from
.prototypes
import
prepared
as
capi
...
@@ -18,6 +17,7 @@ class PreparedGeometry(GEOSBase):
...
@@ -18,6 +17,7 @@ class PreparedGeometry(GEOSBase):
# from being garbage collected which could then crash the prepared one
# from being garbage collected which could then crash the prepared one
# See #21662
# See #21662
self
.
_base_geom
=
geom
self
.
_base_geom
=
geom
from
.geometry
import
GEOSGeometry
if
not
isinstance
(
geom
,
GEOSGeometry
):
if
not
isinstance
(
geom
,
GEOSGeometry
):
raise
TypeError
raise
TypeError
self
.
ptr
=
capi
.
geos_prepare
(
geom
.
ptr
)
self
.
ptr
=
capi
.
geos_prepare
(
geom
.
ptr
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment