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

Error when debug = True #2

Open
berbaba opened this issue Oct 8, 2021 · 6 comments
Open

Error when debug = True #2

berbaba opened this issue Oct 8, 2021 · 6 comments

Comments

@berbaba
Copy link
Contributor

berbaba commented Oct 8, 2021

If we call the Fence class method check_point with the parameter debug being true, an error raises due to the variables max_x, min_x, max_y, min_y not being defined previously to their use.

AttributeError: 'Fence' object has no attribute 'max_x'
@sam-drew
Copy link
Owner

Hi! To better understand what's causing the issue, could you please include a snippet of the code that produced the error?

@berbaba
Copy link
Contributor Author

berbaba commented Oct 20, 2021

Hello, thanks for replying. Of course, this is a simplified version of my code that raises the exception:

import picket
# This function creates the fence from a tuple (of any length) of 2 element tuples (coordenates)
def DefinirTanca(*points):                      
    my_fence = picket.Fence()
    for point in points[0]:
        my_fence.add_point(point)
    return my_fence  

# A group of coordinates defining a square
vlc0_points = ((39.49096,-0.35874),(39.49096,-0.17000),(39.37108,-0.17000),(39.37108,-0.35874))

# Call to create a fence object
VLC0_fence  = DefinirTanca(vlc0_points)

# This function checks if a given point is inside the given fence.
# Returns tuple with boolean and the fence (useful if checking multiple fences). 
# Takes also the boolean parameter to activate debugging option.
def Atrapat(fence, punt, ver = True):
    if fence.check_point((punt[0],punt[1]),debug = ver): 
        trobat = (True,fence)
    else:
        trobat = (False,0)
    return trobat

# We call the function with 4 combinations of points inside/outside the given fence
#  and with True/False for the debugging option.
Atrapat(VLC0_fence,(0,0),ver=False)   
print("\n")
Atrapat(VLC0_fence,(39.40,-0.30),ver=False)  
print("\n")
Atrapat(VLC0_fence,(0,0),ver=True)   
print("\n")
Atrapat(VLC0_fence,(39.40,-0.30),ver=True)   

Running this script the error will arise with the calls to the function that uses check_point with the debugging activated.

berbaba added a commit to berbaba/picket that referenced this issue Oct 20, 2021
This line (169) commented solves the issue sam-drew#2 . I guess that line was intended to show us the value of some variables (max and min of x and y for the fence) that are not in the code anymore.
@sam-drew
Copy link
Owner

Thanks for the updated info. Your pull request does seem to fix this (I'll merge it in a second!). To be totally honest I haven't looked at this project in a looooooong time. If it's something you find useful, we could look at improving it?

@berbaba
Copy link
Contributor Author

berbaba commented Oct 27, 2021

Hi. Yes, it is useful to me, thank you.
It works fine for my needs so I'm not sure what could be improved (also not an expert programmer).
The only other change I've made was to print less on screen when not debugging (I have to check if long lists of coordinates are inside of several geofences) so it was too verbose. I could do a pull request if you think that is useful.

@berbaba
Copy link
Contributor Author

berbaba commented Nov 12, 2021

Thanks for the updated info. Your pull request does seem to fix this (I'll merge it in a second!). To be totally honest I haven't looked at this project in a looooooong time. If it's something you find useful, we could look at improving it?

Hello @sam-drew , related to your question about if I could help improving, my program uses the geofence objects created by the library and then prints a map with those geofences (and the points I'm checking) because it helps a lot tracking the trajectories and double checking if everything is right. Example:
Map showing some rectangular geofences and trajectories going through them

Also I'm trying to implement the use of kml / kmz files (kml is a text file with XML structure and kmz is a compressed kml) comonly used by Google Earth or OpenStreetMap to represent objects on maps. Maybe being able to import them to define a geofence or to export a geofence into a kml file.

If any of those features look interesting for you to add to the library I can try doing it.
Thank you
Bernat

@sam-drew
Copy link
Owner

Absolutely, those certainly seem like useful features. I'm not sure that I will have much time to help out, but if you want to go ahead yourself then please do :)

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

No branches or pull requests

2 participants