michplunkett / ucpd-incident-scraper

This code is going to be used to scrape the UCPD Daily Incident page at a pre-determined frequency and store the incidents on a generic JSON data-store.
MIT License
3 stars 2 forks source link

Address Incidents with swapped longitude and latitudes #38

Closed michplunkett closed 10 months ago

michplunkett commented 10 months ago

What issue are you seeing or what feature needs to be added?

Correct recorded incidents where the longitude and latitude coordinates are swapped.

Screenshot 2024-01-07 at 6 31 18 PM

Useful Information

It seems like there might be a slight confusion in your question. Google Cloud Datastore, which is often associated with Google App Engine, uses the GeoPt property to represent geographical points, and you can query entities based on their geographical properties.

Assuming you have a model with a GeoPtProperty and you want to query entities based on their geographical coordinates (latitude and longitude), you can use the following example:

from google.cloud import datastore

# Create a client
client = datastore.Client()

# Define your query
query = client.query(kind='YourEntityKind')

# Add a filter for latitude and longitude range
query.add_filter('geo_point_property_name', '>=', datastore.GeoPoint(min_latitude, min_longitude))
query.add_filter('geo_point_property_name', '<=', datastore.GeoPoint(max_latitude, max_longitude))

# Execute the query
result = list(query.fetch())

# Now, 'result' contains the entities that match your geographical criteria

Replace 'YourEntityKind' with the actual kind of your entity, and replace 'geo_point_property_name' with the actual name of your GeoPtProperty.

Adjust min_latitude, min_longitude, max_latitude, and max_longitude according to the geographical range you want to query.

Make sure you have the google-cloud-datastore library installed (pip install google-cloud-datastore).

If you are using a different Google service like Google Cloud Firestore or Google Maps APIs, the process might be different, and you would need to refer to the respective documentation for querying geo-coordinates.