Metadata-Version: 2.4
Name: py-sensor-things
Version: 0.1.1
Summary: Python packages for Sensor Thing API with request `https` 
Author-email: Tberg <theo.berguig@free.fr>
License-Expression: BSD-3-Clause AND CC-BY-NC-4.0
Classifier: Development Status :: 3 - Alpha
Classifier: Topic :: System :: Monitoring
Classifier: Topic :: Scientific/Engineering :: GIS
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Requires-Python: >=3.12
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: license-file

# Python POC implementing standard for STA OGC API for real python

[![License: CC BY-NC 4.0](https://img.shields.io/badge/License-CC_BY--NC_4.0-lightgrey.svg?style=for-the-badge)](https://creativecommons.org/licenses/by-nc/4.0/)
![Python](https://img.shields.io/badge/python-3670A0?style=for-the-badge&logo=python&logoColor=ffdd54)
[![Static Badge OGC WPS](https://img.shields.io/badge/OGC-STApi-lightgreen?style=for-the-badge)](https://www.ogc.org/standards/sensorthings/)

## Constate

This programme is an interface like : 

~~~
┌───────────────┐    ┌...........┐    ┌───────────────┐
│ Client Python │──────▶  HTTP  ─────▶│ Serveur   STA │
└───────────────┘    └...........┘    └───────────────┘
       ▲                                    │
       └────────────────────────────────────┘
                Give back data
~~~

## Usage: 

~~~python
from py_sta.model_sta import ModelSTA

url_sta = "http://.../v1.1/"

service = ModelSTA(url_sta)
# return pure dict object
model = (
        service.observations()
        .top(5)
        .count()
        .expand("FeatureOfInterest($select=@iot.id,name,feature)")
        .order_by("phenomenonTime asc")
        .execute()
       )

result = [elem for elem in model["value"] ]
df_data = pandas.DataFrame(result)[["@iot.id","phenomenonTime","result"]]
# out 
   @iot.id        phenomenonTime  result
0    47091  2025-02-09T15:10:00Z   515.0
1    47203  2025-02-09T15:10:00Z  1941.0
2    47092  2025-02-09T15:20:00Z   516.0
3    47204  2025-02-09T15:20:00Z  1950.0
4    47093  2025-02-09T15:30:00Z   516.0
~~~


### Print info 

~~~py
>>> service.info()
╭──────────────────────────────────────────────────────────────────────────────────────────────────────╮
🌐 URL: https://data.geoscience.fr/api/stapi/surfacewater/insitu/v1.1/
      📅 Date min: 2025-02-09 15:10:00

      📅 Date max: 2025-08-11 15:15:00
╰──────────────────────────────────────────────────────────────────────────────────────────────────────╯

                            Route:
╭─────────────────────┬──────────────────────────────────────────────╮
│ Name                │ endpoint                                     │
├─────────────────────┼──────────────────────────────────────────────┤
│ Datastreams         │ surfacewater/insitu/v1.1/Datastreams         │
│ FeaturesOfInterest  │ surfacewater/insitu/v1.1/FeaturesOfInterest  │
│ HistoricalLocations │ surfacewater/insitu/v1.1/HistoricalLocations │
│ Locations           │ surfacewater/insitu/v1.1/Locations           │
│ Observations        │ surfacewater/insitu/v1.1/Observations        │
│ ObservedProperties  │ surfacewater/insitu/v1.1/ObservedProperties  │
│ Sensors             │ surfacewater/insitu/v1.1/Sensors             │
│ Things              │ surfacewater/insitu/v1.1/Things              │
╰─────────────────────┴──────────────────────────────────────────────╯
~~~

## Next step

- [ ] TODO

# Credit 

> [!IMPORTANT] 
> Auteur : **Théo BERGUIG**
>
> No commercial, using code, contribute of code for projet **AND add cite this project**.
>
> **Date** : <ins>05/06/2026</ins>
