simplestmaps 1.5.0__tar.gz → 1.7.0__tar.gz

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.
@@ -0,0 +1,61 @@
1
+ Metadata-Version: 2.1
2
+ Name: simplestmaps
3
+ Version: 1.7.0
4
+ Summary: Super simple on-liner maps in python.
5
+ Home-page: http://github.com/fisadev/simplestmaps
6
+ Author: Juan Pedro Fisanotti
7
+ Author-email: fisadev@gmail.com
8
+ License: MIT
9
+ Classifier: Intended Audience :: Developers
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Natural Language :: English
12
+ Classifier: Operating System :: OS Independent
13
+ Classifier: Programming Language :: Python
14
+ Classifier: Programming Language :: Python :: 3
15
+ Description-Content-Type: text/markdown
16
+ License-File: LICENSE
17
+
18
+ # Simplest Maps
19
+
20
+ Super simple on-liner maps in python.
21
+
22
+ # Installation
23
+
24
+ `pip3 install simplestmaps`
25
+
26
+ # Usage
27
+
28
+ This lib aims to be super simple to use. For instance, to draw a markers and an area, you could do something like this:
29
+
30
+ ```python
31
+ from simplestmaps import draw_map, area, marker
32
+
33
+ draw_map(
34
+ marker(-31.2526, -61.4917, popup="my hometown"),
35
+ area([(-31.2741, -61.5105), (-31.2872, -61.5137), (-31.2895, -61.5003), (-31.2764, -61.4973)], color="green", popup="our airfield"),
36
+ )
37
+ ```
38
+
39
+ ![example map](./docs/readme_example1.png)
40
+
41
+ It can even do more advanced stuff, like plotting the contents of a geojson file (points, areas, lines):
42
+
43
+ ```python
44
+ from simplestmaps import draw_map, geojson
45
+
46
+ draw_map(
47
+ geojson("./docs/readme_example.geojson"),
48
+ )
49
+ ```
50
+
51
+ ![example map](./docs/readme_example2.png)
52
+
53
+ SimplestMaps can plot markers, dots, labels (text), custom html, lines, areas and geojsons, and all of that can be combined in every map.
54
+
55
+ And every element plotted into the map is also customizable (colors, fonts, sizes, popups, etc).
56
+
57
+ # More demos and docs
58
+
59
+ Here are a good set of examples that showcase (and document) all of the supported features:
60
+
61
+ ## [Take a look at everything that's possible with so little code!](https://simplestmaps.fisadev.com/)
@@ -19,7 +19,7 @@ draw_map(
19
19
  )
20
20
  ```
21
21
 
22
- ![example map](./readme_example1.png)
22
+ ![example map](./docs/readme_example1.png)
23
23
 
24
24
  It can even do more advanced stuff, like plotting the contents of a geojson file (points, areas, lines):
25
25
 
@@ -27,11 +27,11 @@ It can even do more advanced stuff, like plotting the contents of a geojson file
27
27
  from simplestmaps import draw_map, geojson
28
28
 
29
29
  draw_map(
30
- geojson("./readme_example.geojson"),
30
+ geojson("./docs/readme_example.geojson"),
31
31
  )
32
32
  ```
33
33
 
34
- ![example map](./readme_example2.png)
34
+ ![example map](./docs/readme_example2.png)
35
35
 
36
36
  SimplestMaps can plot markers, dots, labels (text), custom html, lines, areas and geojsons, and all of that can be combined in every map.
37
37
 
@@ -41,4 +41,4 @@ And every element plotted into the map is also customizable (colors, fonts, size
41
41
 
42
42
  Here are a good set of examples that showcase (and document) all of the supported features:
43
43
 
44
- ## [Take a look at everything that's possible with so little code!](https://nbviewer.org/github/fisadev/simplestmaps/blob/59c84384463eb31eb827e2ec42cb40f2f502ff58/demo_and_docs.ipynb)
44
+ ## [Take a look at everything that's possible with so little code!](https://simplestmaps.fisadev.com/)
@@ -3,7 +3,7 @@ from setuptools import setup
3
3
 
4
4
  setup(
5
5
  name="simplestmaps",
6
- version="1.5.0",
6
+ version="1.7.0",
7
7
  description="Super simple on-liner maps in python.",
8
8
  long_description=open("README.md").read(),
9
9
  long_description_content_type="text/markdown",
@@ -0,0 +1,61 @@
1
+ Metadata-Version: 2.1
2
+ Name: simplestmaps
3
+ Version: 1.7.0
4
+ Summary: Super simple on-liner maps in python.
5
+ Home-page: http://github.com/fisadev/simplestmaps
6
+ Author: Juan Pedro Fisanotti
7
+ Author-email: fisadev@gmail.com
8
+ License: MIT
9
+ Classifier: Intended Audience :: Developers
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Natural Language :: English
12
+ Classifier: Operating System :: OS Independent
13
+ Classifier: Programming Language :: Python
14
+ Classifier: Programming Language :: Python :: 3
15
+ Description-Content-Type: text/markdown
16
+ License-File: LICENSE
17
+
18
+ # Simplest Maps
19
+
20
+ Super simple on-liner maps in python.
21
+
22
+ # Installation
23
+
24
+ `pip3 install simplestmaps`
25
+
26
+ # Usage
27
+
28
+ This lib aims to be super simple to use. For instance, to draw a markers and an area, you could do something like this:
29
+
30
+ ```python
31
+ from simplestmaps import draw_map, area, marker
32
+
33
+ draw_map(
34
+ marker(-31.2526, -61.4917, popup="my hometown"),
35
+ area([(-31.2741, -61.5105), (-31.2872, -61.5137), (-31.2895, -61.5003), (-31.2764, -61.4973)], color="green", popup="our airfield"),
36
+ )
37
+ ```
38
+
39
+ ![example map](./docs/readme_example1.png)
40
+
41
+ It can even do more advanced stuff, like plotting the contents of a geojson file (points, areas, lines):
42
+
43
+ ```python
44
+ from simplestmaps import draw_map, geojson
45
+
46
+ draw_map(
47
+ geojson("./docs/readme_example.geojson"),
48
+ )
49
+ ```
50
+
51
+ ![example map](./docs/readme_example2.png)
52
+
53
+ SimplestMaps can plot markers, dots, labels (text), custom html, lines, areas and geojsons, and all of that can be combined in every map.
54
+
55
+ And every element plotted into the map is also customizable (colors, fonts, sizes, popups, etc).
56
+
57
+ # More demos and docs
58
+
59
+ Here are a good set of examples that showcase (and document) all of the supported features:
60
+
61
+ ## [Take a look at everything that's possible with so little code!](https://simplestmaps.fisadev.com/)
@@ -24,20 +24,25 @@ def all_numbers(sequence):
24
24
  )
25
25
 
26
26
 
27
- def to_points(source):
27
+ def to_points(source, inverted_tuples=False):
28
28
  """
29
29
  Convert any possible thing to lat lon points and/or sequences of points.
30
+ Optionally reverse lat,lon values (used when converting points from lists of coordinates in
31
+ geojsons).
30
32
  """
31
33
  while source.__class__ in converters:
32
34
  # a custom type for which we have a converter registered, use it before trying to extract
33
35
  # points from it
34
36
  source = converters[source.__class__](source)
35
37
 
36
- if isinstance(source, GeneratorType):
38
+ if isinstance(source, Point):
39
+ # don't re-convert things that are already points
40
+ return source
41
+ elif isinstance(source, GeneratorType):
37
42
  # traverse the generator and build a tuple with its components, that we can inspect and
38
43
  # parse (so we can do things like decide how to parse it based on its length and the types
39
44
  # of its items)
40
- return to_points(tuple(source))
45
+ return to_points(tuple(source), inverted_tuples=inverted_tuples)
41
46
  elif hasattr(source, "lat") and hasattr(source, "lon"):
42
47
  # a few known classes that have lat long attributes
43
48
  lat, lon = source.lat, source.lon
@@ -49,18 +54,25 @@ def to_points(source):
49
54
  # a few known classes that have latitude_deg longitude_deg attributes, like the
50
55
  # locations from the orbit-predictor lib
51
56
  lat, lon = source.latitude_deg, source.longitude_deg
57
+ elif source.__class__.__name__ == "Position" and hasattr(source, "position_llh"):
58
+ # a known class from the orbit-predictor lib, which has ECEF coordinates but can easily
59
+ # produce lat, lon, height coords
60
+ lat, lon, _ = source.position_llh
52
61
  elif isinstance(source, (tuple, list)):
53
62
  if len(source) == 1:
54
63
  # a sequence with a single object inside, so extract a point from it as if we just got
55
64
  # that object alone
56
- return to_points(source[0])
65
+ return to_points(source[0], inverted_tuples=inverted_tuples)
57
66
  elif len(source) in (2, 3) and all_numbers(source):
58
67
  # a sequence of 2 or 3 numbers, these must be coordinates, finally!
59
- lat, lon = source[:2]
68
+ if inverted_tuples:
69
+ lon, lat = source[:2]
70
+ else:
71
+ lat, lon = source[:2]
60
72
  else:
61
73
  # a sequence that doesn't look like coordinates but maybe a collection of points, try
62
74
  # to extract all of them into a list
63
- return [to_points(item) for item in source]
75
+ return [to_points(item, inverted_tuples=inverted_tuples) for item in source]
64
76
  else:
65
77
  raise ValueError(
66
78
  f"Can't guess the latitude and longitude from this object: {repr(source)}"
@@ -278,27 +290,21 @@ def geojson(path_or_data, points_as=marker, lines_as=line, areas_as=area):
278
290
  # a collection of features, extract them individually
279
291
  for feature in geojson_data["features"]:
280
292
  yield from geojson(feature["geometry"], points_as, lines_as, areas_as)
281
-
282
293
  elif geojson_type == "Point":
283
- # geojson uses lon,lat instead of lat,lon
284
- raw_coords = geojson_data["coordinates"]
285
- yield points_as(raw_coords[1], raw_coords[0])
286
-
294
+ yield points_as(
295
+ extract_single_points(to_points(geojson_data["coordinates"],
296
+ inverted_tuples=True))
297
+ )
287
298
  elif geojson_type == "LineString":
288
- # geojson uses lon,lat instead of lat,lon
289
- raw_coords_sequence = geojson_data["coordinates"]
290
299
  yield lines_as(
291
- (raw_coords[1], raw_coords[0])
292
- for raw_coords in raw_coords_sequence
300
+ extract_points_sequences(to_points(geojson_data["coordinates"],
301
+ inverted_tuples=True))
302
+ )
303
+ elif geojson_type in ("Polygon", "MultiPolygon"):
304
+ yield areas_as(
305
+ extract_points_sequences(to_points(geojson_data["coordinates"],
306
+ inverted_tuples=True))
293
307
  )
294
-
295
- elif geojson_type == "Polygon":
296
- # geojson uses lon,lat instead of lat,lon. And polygons have lists of lists of coords
297
- for raw_coords_sequence in geojson_data["coordinates"]:
298
- yield areas_as(
299
- (raw_coords[1], raw_coords[0])
300
- for raw_coords in raw_coords_sequence
301
- )
302
308
 
303
309
 
304
310
  def draw_map(*things, center=(0, 0), zoom=1.5, tiles="cartodbpositron"):
@@ -1,61 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: simplestmaps
3
- Version: 1.5.0
4
- Summary: Super simple on-liner maps in python.
5
- Home-page: http://github.com/fisadev/simplestmaps
6
- Author: Juan Pedro Fisanotti
7
- Author-email: fisadev@gmail.com
8
- License: MIT
9
- Description: # Simplest Maps
10
-
11
- Super simple on-liner maps in python.
12
-
13
- # Installation
14
-
15
- `pip3 install simplestmaps`
16
-
17
- # Usage
18
-
19
- This lib aims to be super simple to use. For instance, to draw a markers and an area, you could do something like this:
20
-
21
- ```python
22
- from simplestmaps import draw_map, area, marker
23
-
24
- draw_map(
25
- marker(-31.2526, -61.4917, popup="my hometown"),
26
- area([(-31.2741, -61.5105), (-31.2872, -61.5137), (-31.2895, -61.5003), (-31.2764, -61.4973)], color="green", popup="our airfield"),
27
- )
28
- ```
29
-
30
- ![example map](./readme_example1.png)
31
-
32
- It can even do more advanced stuff, like plotting the contents of a geojson file (points, areas, lines):
33
-
34
- ```python
35
- from simplestmaps import draw_map, geojson
36
-
37
- draw_map(
38
- geojson("./readme_example.geojson"),
39
- )
40
- ```
41
-
42
- ![example map](./readme_example2.png)
43
-
44
- SimplestMaps can plot markers, dots, labels (text), custom html, lines, areas and geojsons, and all of that can be combined in every map.
45
-
46
- And every element plotted into the map is also customizable (colors, fonts, sizes, popups, etc).
47
-
48
- # More demos and docs
49
-
50
- Here are a good set of examples that showcase (and document) all of the supported features:
51
-
52
- ## [Take a look at everything that's possible with so little code!](https://nbviewer.org/github/fisadev/simplestmaps/blob/59c84384463eb31eb827e2ec42cb40f2f502ff58/demo_and_docs.ipynb)
53
-
54
- Platform: UNKNOWN
55
- Classifier: Intended Audience :: Developers
56
- Classifier: License :: OSI Approved :: MIT License
57
- Classifier: Natural Language :: English
58
- Classifier: Operating System :: OS Independent
59
- Classifier: Programming Language :: Python
60
- Classifier: Programming Language :: Python :: 3
61
- Description-Content-Type: text/markdown
@@ -1,61 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: simplestmaps
3
- Version: 1.5.0
4
- Summary: Super simple on-liner maps in python.
5
- Home-page: http://github.com/fisadev/simplestmaps
6
- Author: Juan Pedro Fisanotti
7
- Author-email: fisadev@gmail.com
8
- License: MIT
9
- Description: # Simplest Maps
10
-
11
- Super simple on-liner maps in python.
12
-
13
- # Installation
14
-
15
- `pip3 install simplestmaps`
16
-
17
- # Usage
18
-
19
- This lib aims to be super simple to use. For instance, to draw a markers and an area, you could do something like this:
20
-
21
- ```python
22
- from simplestmaps import draw_map, area, marker
23
-
24
- draw_map(
25
- marker(-31.2526, -61.4917, popup="my hometown"),
26
- area([(-31.2741, -61.5105), (-31.2872, -61.5137), (-31.2895, -61.5003), (-31.2764, -61.4973)], color="green", popup="our airfield"),
27
- )
28
- ```
29
-
30
- ![example map](./readme_example1.png)
31
-
32
- It can even do more advanced stuff, like plotting the contents of a geojson file (points, areas, lines):
33
-
34
- ```python
35
- from simplestmaps import draw_map, geojson
36
-
37
- draw_map(
38
- geojson("./readme_example.geojson"),
39
- )
40
- ```
41
-
42
- ![example map](./readme_example2.png)
43
-
44
- SimplestMaps can plot markers, dots, labels (text), custom html, lines, areas and geojsons, and all of that can be combined in every map.
45
-
46
- And every element plotted into the map is also customizable (colors, fonts, sizes, popups, etc).
47
-
48
- # More demos and docs
49
-
50
- Here are a good set of examples that showcase (and document) all of the supported features:
51
-
52
- ## [Take a look at everything that's possible with so little code!](https://nbviewer.org/github/fisadev/simplestmaps/blob/59c84384463eb31eb827e2ec42cb40f2f502ff58/demo_and_docs.ipynb)
53
-
54
- Platform: UNKNOWN
55
- Classifier: Intended Audience :: Developers
56
- Classifier: License :: OSI Approved :: MIT License
57
- Classifier: Natural Language :: English
58
- Classifier: Operating System :: OS Independent
59
- Classifier: Programming Language :: Python
60
- Classifier: Programming Language :: Python :: 3
61
- Description-Content-Type: text/markdown
File without changes
File without changes