Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Visualize geofences on front-end #2171

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

IcognitoUnown
Copy link

PRing the visualization of the geofences after the initial functionality merge.

Description

This PR adds a DB table geofence to retrieve data in app.py for the front-end. No additional flags have to be set. When one regular geofence flag is set, this option becomes automatically available as switch button in the front-end.
Make sure your geofences do not have duplicate names. The same geofence with the same name is fine, when used in multiple instances.

Motivation and Context

Geofences are a great tool for RocketMap to outline areas of interest or restricted ones. To make this transparent, we want to show it to the users as well as "debug" our geofences itself if they are drawn correctly.

How Has This Been Tested?

This was tested on my local machine.

Types of changes

  • New feature (non-breaking change which adds functionality)

Checklist:

  • My code follows the code style of this project.

pogom/models.py Outdated
Geofence.remove_duplicates(geofences)

db_geofences = []
id = 0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

id is not needed, isn't it?


@staticmethod
def get_geofences():
query = Geofence.select().dicts()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Control the situation when there are no geofences.
I know that this should be called in that situation but you never know.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is controlled by just returning an empty query which doesn't get looped due to for gf in query and returns am empty array geofences.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SiteEffect Peewee raises an exception if there are not data, not an empty iterable, not sure why

@friscoMad
Copy link
Contributor

Not sure if I would delete all and insert every fence on load instead of replacing, the difference in timing should be neglible and you avoid problems when changing the fence and leaving the same name.

Also not sure if this handles properly fences without name (not sure if it is allowed by RM but think so).

@friscoMad
Copy link
Contributor

Also it came to my mind recently that this does not handle different instances, not sure if we want to show all geofences from all instances in all maps, but if 2 instances have different fences with the same name, it will show the last one that was imported.

@SiteEffect
Copy link
Contributor

@friscoMad intended behaviour. Either you use the same name for two geofences or the same geofence on two instances, which then should contain the same content as well or you should alter the name of one when two geofences contain different content.

@tomballgithub
Copy link
Contributor

Is there a way to show geofences that are not active in Rocketmap? For example, I am not using geofences in Rocketmap but would love to be able to load (even via database manipulation) my PokeAlarm geofences so the users can see them.

@elincognito
Copy link
Contributor

Can you fix the conflicts @IcognitoUnown 😉

@sirlindqvist
Copy link
Contributor

Rebase??

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants