1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
|
%global _empty_manifest_terminate_build 0
Name: python-geopip
Version: 1.1
Release: 1
Summary: Reverse geocode a lng/lat coordinate within a geojson FeatureCollection.
License: MIT
URL: https://github.com/tammoippen/geopip
Source0: https://mirrors.nju.edu.cn/pypi/web/packages/f8/68/6915c368d8ca24f1b8e91b3184241fc9a6379ff0fd39f9b949ed5a835037/geopip-1.1.tar.gz
BuildArch: noarch
%description
|Build Status| |Coverage Status| |Tested CPython Versions| |Tested PyPy
Versions| |PyPi version| |PyPi license|
Reverse geocode a lng/lat coordinate within a geojson
``FeatureCollection`` and return information about the containing
country (polygon).
Basically, you can use any
`geojson <https://tools.ietf.org/html/rfc7946>`__ file (top level is a
``FeatureCollection``) for reverse coding - set the environment variable
``REVERSE_GEOCODE_DATA`` to the geojson file. Only ``Polygon`` and
``MultiPolygon`` features will be used! If a point is found to be in a
feature, the ``properties`` of that feature will be returned.
In other words, provide a geojson with postcode boundaries, and you can
query for the postcode in which a coordinate is. Provide timezone
boundaries and you can find the timezone for a coordinate. Be creative
The default shape data (contained within the package) is from
`thematicmapping <http://thematicmapping.org/downloads/world_borders.php>`__
(the simple shapes). It contains polygons representing one country with
the following meta-data (``properties``):
FIPS String(2) FIPS 10-4 Country Code
ISO2 String(2) ISO 3166-1 Alpha-2 Country Code
ISO3 String(3) ISO 3166-1 Alpha-3 Country Code
UN Short Integer(3) ISO 3166-1 Numeric-3 Country Code
NAME String(50) Name of country/area
AREA Long Integer(7) Land area, FAO Statistics (2002)
POP2005 Double(10,0) Population, World Population Prospects (2005)
REGION Short Integer(3) Macro geographical (continental region), UN Statistics
SUBREGION Short Integer(3) Geographical sub-region, UN Statistics
LON FLOAT (7,3) Longitude
LAT FLOAT (6,3) Latitude
Hence, you can use this package as an *offline reverse geocoder on the
country level* (by default):
In [1]: import geopip
In [2]: geopip.search(lng=4.910248, lat=50.850981)
Out[2]:
{'AREA': 0,
'FIPS': 'BE',
'ISO2': 'BE',
'ISO3': 'BEL',
'LAT': 50.643,
'LON': 4.664,
'NAME': 'Belgium',
'POP2005': 10398049,
'REGION': 150,
'SUBREGION': 155,
'UN': 56}
**NOTE**: Since the polygons for each country are quite simple, reverse
geocoding at the borders of two countrys is **not** exact. Use polygons
with higher resolution for these use cases (see `Data <#data>`__).
The ``shapely`` package will be used, if installed. Otherwise, a pure
python implementation will be used (on the basis of `winding
numbers <https://en.wikipedia.org/wiki/Winding_number>`__). See
`here <https://www.toptal.com/python/computational-geometry-in-python-from-theory-to-implementation>`__,
`here <http://geomalgorithms.com/a03-_inclusion.html>`__ and
`here <http://www.dgp.toronto.edu/~mac/e-stuff/point_in_polygon.py>`__
for more informations and example implementations. Espacially for larger
features, the shapely implementation might give performance improvements
(default shape data and 2.6 GHz Intel Core i7, python3.6.2, cythonized
version of
`geohash-hilbert <https://github.com/tammoippen/geohash-hilbert>`__):
*Pure*:
In [1]: import geopip
In [2]: geopip._geopip.p_in_polygon?
Signature: geopip._geopip.p_in_polygon(p, shp)
Docstring:
Test, whether point `p` is in shape `shp`.
Use the pure python implementation for this.
Parameters:
p: Tuple[float, float] Point (lng, lat) in WGS84.
shp: Dict[str, Any] Prepared shape dictionary from `geopip._pure.prepare()`.
Returns:
boolean: True, if p in shp, False otherwise
File: ~/repositories/geopip/geopip/_pure.py
Type: function
In [3]: %timeit geopip.search(4.910248, 50.850981)
25.6 µs ± 390 ns per loop (mean ± std. dev. of 7 runs, 10000 loops each)
*Shapely*:
In [1]: import geopip
In [2]: geopip_geopip.p_in_polygon?
Signature: geopip._geopip.p_in_polygon(p, shp)
Docstring:
Test, whether point `p` is in shape `shp`.
Use the shapely implementation for this.
Parameters:
p: Tuple[float, float] Point (lng, lat) in WGS84.
shp: Dict[str, Any] Prepared shape dictionary from `geopip._shapely.prepare()`.
Returns:
boolean: True, if p in shp, False otherwise
File: ~/repositories/geopip/geopip/_shapely.py
Type: function
In [3]: %timeit geopip.search(4.910248, 50.850981)
50 µs ± 601 ns per loop (mean ± std. dev. of 7 runs, 10000 loops each)
For simple geojsons, the pure python implementation is faster, but on
more complex polygons, the shapely implementation will win.
%package -n python3-geopip
Summary: Reverse geocode a lng/lat coordinate within a geojson FeatureCollection.
Provides: python-geopip
BuildRequires: python3-devel
BuildRequires: python3-setuptools
BuildRequires: python3-pip
%description -n python3-geopip
|Build Status| |Coverage Status| |Tested CPython Versions| |Tested PyPy
Versions| |PyPi version| |PyPi license|
Reverse geocode a lng/lat coordinate within a geojson
``FeatureCollection`` and return information about the containing
country (polygon).
Basically, you can use any
`geojson <https://tools.ietf.org/html/rfc7946>`__ file (top level is a
``FeatureCollection``) for reverse coding - set the environment variable
``REVERSE_GEOCODE_DATA`` to the geojson file. Only ``Polygon`` and
``MultiPolygon`` features will be used! If a point is found to be in a
feature, the ``properties`` of that feature will be returned.
In other words, provide a geojson with postcode boundaries, and you can
query for the postcode in which a coordinate is. Provide timezone
boundaries and you can find the timezone for a coordinate. Be creative
The default shape data (contained within the package) is from
`thematicmapping <http://thematicmapping.org/downloads/world_borders.php>`__
(the simple shapes). It contains polygons representing one country with
the following meta-data (``properties``):
FIPS String(2) FIPS 10-4 Country Code
ISO2 String(2) ISO 3166-1 Alpha-2 Country Code
ISO3 String(3) ISO 3166-1 Alpha-3 Country Code
UN Short Integer(3) ISO 3166-1 Numeric-3 Country Code
NAME String(50) Name of country/area
AREA Long Integer(7) Land area, FAO Statistics (2002)
POP2005 Double(10,0) Population, World Population Prospects (2005)
REGION Short Integer(3) Macro geographical (continental region), UN Statistics
SUBREGION Short Integer(3) Geographical sub-region, UN Statistics
LON FLOAT (7,3) Longitude
LAT FLOAT (6,3) Latitude
Hence, you can use this package as an *offline reverse geocoder on the
country level* (by default):
In [1]: import geopip
In [2]: geopip.search(lng=4.910248, lat=50.850981)
Out[2]:
{'AREA': 0,
'FIPS': 'BE',
'ISO2': 'BE',
'ISO3': 'BEL',
'LAT': 50.643,
'LON': 4.664,
'NAME': 'Belgium',
'POP2005': 10398049,
'REGION': 150,
'SUBREGION': 155,
'UN': 56}
**NOTE**: Since the polygons for each country are quite simple, reverse
geocoding at the borders of two countrys is **not** exact. Use polygons
with higher resolution for these use cases (see `Data <#data>`__).
The ``shapely`` package will be used, if installed. Otherwise, a pure
python implementation will be used (on the basis of `winding
numbers <https://en.wikipedia.org/wiki/Winding_number>`__). See
`here <https://www.toptal.com/python/computational-geometry-in-python-from-theory-to-implementation>`__,
`here <http://geomalgorithms.com/a03-_inclusion.html>`__ and
`here <http://www.dgp.toronto.edu/~mac/e-stuff/point_in_polygon.py>`__
for more informations and example implementations. Espacially for larger
features, the shapely implementation might give performance improvements
(default shape data and 2.6 GHz Intel Core i7, python3.6.2, cythonized
version of
`geohash-hilbert <https://github.com/tammoippen/geohash-hilbert>`__):
*Pure*:
In [1]: import geopip
In [2]: geopip._geopip.p_in_polygon?
Signature: geopip._geopip.p_in_polygon(p, shp)
Docstring:
Test, whether point `p` is in shape `shp`.
Use the pure python implementation for this.
Parameters:
p: Tuple[float, float] Point (lng, lat) in WGS84.
shp: Dict[str, Any] Prepared shape dictionary from `geopip._pure.prepare()`.
Returns:
boolean: True, if p in shp, False otherwise
File: ~/repositories/geopip/geopip/_pure.py
Type: function
In [3]: %timeit geopip.search(4.910248, 50.850981)
25.6 µs ± 390 ns per loop (mean ± std. dev. of 7 runs, 10000 loops each)
*Shapely*:
In [1]: import geopip
In [2]: geopip_geopip.p_in_polygon?
Signature: geopip._geopip.p_in_polygon(p, shp)
Docstring:
Test, whether point `p` is in shape `shp`.
Use the shapely implementation for this.
Parameters:
p: Tuple[float, float] Point (lng, lat) in WGS84.
shp: Dict[str, Any] Prepared shape dictionary from `geopip._shapely.prepare()`.
Returns:
boolean: True, if p in shp, False otherwise
File: ~/repositories/geopip/geopip/_shapely.py
Type: function
In [3]: %timeit geopip.search(4.910248, 50.850981)
50 µs ± 601 ns per loop (mean ± std. dev. of 7 runs, 10000 loops each)
For simple geojsons, the pure python implementation is faster, but on
more complex polygons, the shapely implementation will win.
%package help
Summary: Development documents and examples for geopip
Provides: python3-geopip-doc
%description help
|Build Status| |Coverage Status| |Tested CPython Versions| |Tested PyPy
Versions| |PyPi version| |PyPi license|
Reverse geocode a lng/lat coordinate within a geojson
``FeatureCollection`` and return information about the containing
country (polygon).
Basically, you can use any
`geojson <https://tools.ietf.org/html/rfc7946>`__ file (top level is a
``FeatureCollection``) for reverse coding - set the environment variable
``REVERSE_GEOCODE_DATA`` to the geojson file. Only ``Polygon`` and
``MultiPolygon`` features will be used! If a point is found to be in a
feature, the ``properties`` of that feature will be returned.
In other words, provide a geojson with postcode boundaries, and you can
query for the postcode in which a coordinate is. Provide timezone
boundaries and you can find the timezone for a coordinate. Be creative
The default shape data (contained within the package) is from
`thematicmapping <http://thematicmapping.org/downloads/world_borders.php>`__
(the simple shapes). It contains polygons representing one country with
the following meta-data (``properties``):
FIPS String(2) FIPS 10-4 Country Code
ISO2 String(2) ISO 3166-1 Alpha-2 Country Code
ISO3 String(3) ISO 3166-1 Alpha-3 Country Code
UN Short Integer(3) ISO 3166-1 Numeric-3 Country Code
NAME String(50) Name of country/area
AREA Long Integer(7) Land area, FAO Statistics (2002)
POP2005 Double(10,0) Population, World Population Prospects (2005)
REGION Short Integer(3) Macro geographical (continental region), UN Statistics
SUBREGION Short Integer(3) Geographical sub-region, UN Statistics
LON FLOAT (7,3) Longitude
LAT FLOAT (6,3) Latitude
Hence, you can use this package as an *offline reverse geocoder on the
country level* (by default):
In [1]: import geopip
In [2]: geopip.search(lng=4.910248, lat=50.850981)
Out[2]:
{'AREA': 0,
'FIPS': 'BE',
'ISO2': 'BE',
'ISO3': 'BEL',
'LAT': 50.643,
'LON': 4.664,
'NAME': 'Belgium',
'POP2005': 10398049,
'REGION': 150,
'SUBREGION': 155,
'UN': 56}
**NOTE**: Since the polygons for each country are quite simple, reverse
geocoding at the borders of two countrys is **not** exact. Use polygons
with higher resolution for these use cases (see `Data <#data>`__).
The ``shapely`` package will be used, if installed. Otherwise, a pure
python implementation will be used (on the basis of `winding
numbers <https://en.wikipedia.org/wiki/Winding_number>`__). See
`here <https://www.toptal.com/python/computational-geometry-in-python-from-theory-to-implementation>`__,
`here <http://geomalgorithms.com/a03-_inclusion.html>`__ and
`here <http://www.dgp.toronto.edu/~mac/e-stuff/point_in_polygon.py>`__
for more informations and example implementations. Espacially for larger
features, the shapely implementation might give performance improvements
(default shape data and 2.6 GHz Intel Core i7, python3.6.2, cythonized
version of
`geohash-hilbert <https://github.com/tammoippen/geohash-hilbert>`__):
*Pure*:
In [1]: import geopip
In [2]: geopip._geopip.p_in_polygon?
Signature: geopip._geopip.p_in_polygon(p, shp)
Docstring:
Test, whether point `p` is in shape `shp`.
Use the pure python implementation for this.
Parameters:
p: Tuple[float, float] Point (lng, lat) in WGS84.
shp: Dict[str, Any] Prepared shape dictionary from `geopip._pure.prepare()`.
Returns:
boolean: True, if p in shp, False otherwise
File: ~/repositories/geopip/geopip/_pure.py
Type: function
In [3]: %timeit geopip.search(4.910248, 50.850981)
25.6 µs ± 390 ns per loop (mean ± std. dev. of 7 runs, 10000 loops each)
*Shapely*:
In [1]: import geopip
In [2]: geopip_geopip.p_in_polygon?
Signature: geopip._geopip.p_in_polygon(p, shp)
Docstring:
Test, whether point `p` is in shape `shp`.
Use the shapely implementation for this.
Parameters:
p: Tuple[float, float] Point (lng, lat) in WGS84.
shp: Dict[str, Any] Prepared shape dictionary from `geopip._shapely.prepare()`.
Returns:
boolean: True, if p in shp, False otherwise
File: ~/repositories/geopip/geopip/_shapely.py
Type: function
In [3]: %timeit geopip.search(4.910248, 50.850981)
50 µs ± 601 ns per loop (mean ± std. dev. of 7 runs, 10000 loops each)
For simple geojsons, the pure python implementation is faster, but on
more complex polygons, the shapely implementation will win.
%prep
%autosetup -n geopip-1.1
%build
%py3_build
%install
%py3_install
install -d -m755 %{buildroot}/%{_pkgdocdir}
if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi
if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi
if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi
if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi
pushd %{buildroot}
if [ -d usr/lib ]; then
find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst
fi
if [ -d usr/lib64 ]; then
find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst
fi
if [ -d usr/bin ]; then
find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst
fi
if [ -d usr/sbin ]; then
find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst
fi
touch doclist.lst
if [ -d usr/share/man ]; then
find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst
fi
popd
mv %{buildroot}/filelist.lst .
mv %{buildroot}/doclist.lst .
%files -n python3-geopip -f filelist.lst
%dir %{python3_sitelib}/*
%files help -f doclist.lst
%{_docdir}/*
%changelog
* Fri May 05 2023 Python_Bot <Python_Bot@openeuler.org> - 1.1-1
- Package Spec generated
|