geo-engine-python 0.1.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,13 @@
1
+ Metadata-Version: 2.4
2
+ Name: geo-engine-python
3
+ Version: 0.1.0
4
+ Summary: SDK oficial para Geo-Engine: Rastreo y Geofencing
5
+ Author-email: AlexG <alexg695845@gmail.com>
6
+ Project-URL: Homepage, https://geoengine.dev
7
+ Project-URL: Bug Tracker, https://github.com/AlexG695/geo-engine/issues
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: License :: OSI Approved :: MIT License
10
+ Classifier: Operating System :: OS Independent
11
+ Requires-Python: >=3.7
12
+ Description-Content-Type: text/markdown
13
+ Requires-Dist: requests>=2.25.0
@@ -0,0 +1,13 @@
1
+ Metadata-Version: 2.4
2
+ Name: geo-engine-python
3
+ Version: 0.1.0
4
+ Summary: SDK oficial para Geo-Engine: Rastreo y Geofencing
5
+ Author-email: AlexG <alexg695845@gmail.com>
6
+ Project-URL: Homepage, https://geoengine.dev
7
+ Project-URL: Bug Tracker, https://github.com/AlexG695/geo-engine/issues
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: License :: OSI Approved :: MIT License
10
+ Classifier: Operating System :: OS Independent
11
+ Requires-Python: >=3.7
12
+ Description-Content-Type: text/markdown
13
+ Requires-Dist: requests>=2.25.0
@@ -0,0 +1,7 @@
1
+ geoengine.py
2
+ pyproject.toml
3
+ geo_engine_python.egg-info/PKG-INFO
4
+ geo_engine_python.egg-info/SOURCES.txt
5
+ geo_engine_python.egg-info/dependency_links.txt
6
+ geo_engine_python.egg-info/requires.txt
7
+ geo_engine_python.egg-info/top_level.txt
@@ -0,0 +1 @@
1
+ requests>=2.25.0
@@ -0,0 +1,84 @@
1
+ import requests
2
+ import time
3
+ import json
4
+
5
+ class GeoEngine:
6
+ DEFAULT_MANAGEMENT_URL = "https://api.geoengine.dev"
7
+ DEFAULT_INGEST_URL = "http://ingest.geoengine.dev"
8
+
9
+ def __init__(self, api_key, management_url=None, ingest_url=None):
10
+ """
11
+ Inicializa el cliente de GeoEngine.
12
+ """
13
+ if not api_key:
14
+ raise ValueError("GeoEngine: API Key es requerida")
15
+
16
+ self.api_key = api_key
17
+ self.management_url = management_url or self.DEFAULT_MANAGEMENT_URL
18
+ self.ingest_url = ingest_url or self.DEFAULT_INGEST_URL
19
+ self.headers = {
20
+ "Content-Type": "application/json",
21
+ "X-API-Key": self.api_key,
22
+ "User-Agent": "GeoEnginePython/1.0.0"
23
+ }
24
+
25
+ def send_location(self, device_id, lat, lng):
26
+ """
27
+ Envía una coordenada al motor de ingestión.
28
+ """
29
+ payload = {
30
+ "device_id": device_id,
31
+ "latitude": float(lat),
32
+ "longitude": float(lng),
33
+ "timestamp": int(time.time())
34
+ }
35
+
36
+ try:
37
+ response = requests.post(
38
+ f"{self.ingest_url}/ingest",
39
+ json=payload,
40
+ headers=self.headers,
41
+ timeout=10
42
+ )
43
+ response.raise_for_status()
44
+ return response.json()
45
+ except requests.exceptions.RequestException as e:
46
+ raise Exception(f"GeoEngine Error: {e}")
47
+
48
+ def create_geofence(self, name, coordinates, webhook_url):
49
+ """
50
+ Crea una geocerca.
51
+ coordinates debe ser una lista de listas: [[lat, lng], [lat, lng]]
52
+ """
53
+ if len(coordinates) < 3:
54
+ raise ValueError("Se requieren al menos 3 puntos")
55
+
56
+ # Convertir [Lat, Lng] a [Lng, Lat] para GeoJSON
57
+ polygon = [[p[1], p[0]] for p in coordinates]
58
+
59
+ # Cerrar polígono
60
+ if polygon[0] != polygon[-1]:
61
+ polygon.append(polygon[0])
62
+
63
+ payload = {
64
+ "name": name,
65
+ "webhook_url": webhook_url,
66
+ "geojson": {
67
+ "type": "Polygon",
68
+ "coordinates": [polygon]
69
+ }
70
+ }
71
+
72
+ try:
73
+ response = requests.post(
74
+ f"{self.management_url}/geofences",
75
+ json=payload,
76
+ headers=self.headers,
77
+ timeout=10
78
+ )
79
+ response.raise_for_status()
80
+ return response.json()
81
+ except requests.exceptions.RequestException as e:
82
+ if response.content:
83
+ raise Exception(f"API Error: {response.json().get('error', response.text)}")
84
+ raise Exception(f"Connection Error: {e}")
@@ -0,0 +1,25 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "geo-engine-python"
7
+ version = "0.1.0"
8
+ authors = [
9
+ { name="AlexG", email="alexg695845@gmail.com" },
10
+ ]
11
+ description = "SDK oficial para Geo-Engine: Rastreo y Geofencing"
12
+ readme = "README.md"
13
+ requires-python = ">=3.7"
14
+ classifiers = [
15
+ "Programming Language :: Python :: 3",
16
+ "License :: OSI Approved :: MIT License",
17
+ "Operating System :: OS Independent",
18
+ ]
19
+ dependencies = [
20
+ "requests>=2.25.0",
21
+ ]
22
+
23
+ [project.urls]
24
+ "Homepage" = "https://geoengine.dev"
25
+ "Bug Tracker" = "https://github.com/AlexG695/geo-engine/issues"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+