strange behavior for marker created from api

caver456's Avatar

caver456

12 Jul, 2018 02:58 AM

After creating a marker from either the old api (/rest/marker) or the new api (/api/v1/map//Marker), using the corresponding sartopo versions, the marker is created correctly, but has a few problems that don't occur for markers created from the GUI:
1. the marker's label cannot be changed. In the marker's edit dialog, edit the label field, hit OK, and the dialog closes but the label is not changed.
2. the marker's color is black in the map, but red in the left bar.
3. in the edit dialog, the marker's style is an empty box (with black outline) and the color is 'N/A'.
4. when you left-click the marker's name in the left bar to center it and open its popup, the following terminal output shows up, but no js console output is created:
org.springframework.web.util.NestedServletException: Request processing failed; nested exception is java.lang.NullPointerException
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:965) at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:844) at javax.servlet.http.HttpServlet.service(HttpServlet.java:104) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:829) at javax.servlet.http.HttpServlet.service(HttpServlet.java:45) at winstone.ServletConfiguration.execute(ServletConfiguration.java:249) at winstone.RequestDispatcher.forward(RequestDispatcher.java:335) at winstone.RequestDispatcher.doFilter(RequestDispatcher.java:378) at org.sarsoft.common.request.RequestPropertyFilter.doFilter(RequestPropertyFilter.java:42) at winstone.FilterConfiguration.execute(FilterConfiguration.java:195) at winstone.RequestDispatcher.doFilter(RequestDispatcher.java:368) at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:232) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:106) at winstone.FilterConfiguration.execute(FilterConfiguration.java:195) at winstone.RequestDispatcher.doFilter(RequestDispatcher.java:368) at winstone.RequestDispatcher.forward(RequestDispatcher.java:333) at winstone.RequestHandlerThread.processRequest(RequestHandlerThread.java:244) at winstone.RequestHandlerThread.run(RequestHandlerThread.java:150) at java.lang.Thread.run(Unknown Source) Caused by: java.lang.NullPointerException
at org.sarsoft.base.mapping.TileProvider.getTile(TileProvider.java:86) at org.sarsoft.base.mapping.TileProvider.getTile(TileProvider.java:82) at org.sarsoft.base.mapping.LayerProvider.getRGBElevationTile(LayerProvider.java:225) at org.sarsoft.common.imaging.ImageryHandler.getTile(ImageryHandler.java:68) at org.sarsoft.common.imaging.ImageryHandler.handleTileRequest(ImageryHandler.java:98) at org.sarsoft.imaging.ImageryController.getStandardDPITile(ImageryController.java:49) at sun.reflect.GeneratedMethodAccessor76.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:176) at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:440) at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:428) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:919) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:851) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:953) ... 18 more

  1. Support Staff 1 Posted by matt on 12 Jul, 2018 04:20 AM

    matt's Avatar

    Tom -

    Sorry, I don't have a mechanism for notifying people of updates to the API since it's not really meant to be public facing, but before digging any deeper you're aware that the way you represent a marker has changed as well, not just the endpoint?

  2. Support Staff 2 Posted by caver456 on 12 Jul, 2018 05:13 AM

    caver456's Avatar

    I guess I'm not aware of / not remembering that. Interesting timing with
    bigron's related question about the search bar. Our use case is that I
    wrote a small python script to do offline address search with a PyQt
    autocomplete text field, using a table that our county's GIS provided of
    address name / lat / lon. You type in an address (or a street name), it
    gives coordinates, you then hit a button in the PyQt app to create the
    sartopo marker (after the user provides the URL of a saved map). You
    mentioned to Ron that offline address search is coming soon? That would
    win and would maybe make the need for api calls obsolete in this case?
     Regardless, I do still have another pyqt app that creates markers from the
    api so the question remains.

    First I create a folder using the API to put all the address search results
    in:
    DUMP:
    {"label": "Addresses"}
    RESPONSE:
    {'id': '311b384a-381e-4af0-adda-e9bfaf3f7f4c', 'label': 'Addresses',
    'updated': 1531363422712}

    Subsequent address search results are sent with either /rest/marker or
    /api/v1/map/<mapID>/Marker/ based on sartopo version; json data used to
    create the marker is:
    {"label": "234 American Hill", "folderId":
    "311b384a-381e-4af0-adda-e9bfaf3f7f4c", "url": "", "comments": "",
    "position": {"lat": "39.26375264", "lng": "-121.0240284"}}

  3. Support Staff 3 Posted by matt on 12 Jul, 2018 08:48 PM

    matt's Avatar

    It's only for when you have an internet connection, so I wouldn't abandon your project just yet.

    You can use the browser debugger's network log to figure out the correct syntax, but it's geojson while trying to adhere to simplestyle as much as possible. Long-term this will be better for integration with other tools.

    { id: if_it_exists, geometry: { type: "Point", coordinates: [long, lat] }, properties: {title: used_to_be_label, description: used_to_be_comments, folderId: ___, "marker-symbol": "point", "marker-color": "#FF0000"} }

    Folders too: { id: __, properties: { title: __ } }

  4. Support Staff 4 Posted by caver456 on 13 Jul, 2018 01:15 AM

    caver456's Avatar

    Thanks I had not used the browser's debugger network tab before. This is
    what I see when I add a marker from within sartopo on localhost, looks like
    the version I have installed uses an older json data structure? Do yu know
    roughly what sar.jar version# / what date the structure you describe went
    into effect?

    http://localhost:8080/api/v1/map/HNU6/Marker/
    POST
    {"id":null,"folderId":null,"url":"#FF0000","position":{"lat":39.2925,"lng":-121.0549,"id":"ad8efd99-77c1-4a08-8baa-366409ce9fae"},"label":"abcde","comments":""}

  5. Support Staff 5 Posted by matt on 13 Jul, 2018 02:32 AM

    matt's Avatar

    Maybe I misread things and it's unrelated, but this is for sartopo.com and the nightly offline build only, does not apply to any of the stable offline releases.

  6. Support Staff 6 Posted by caver456 on 13 Jul, 2018 03:37 AM

    caver456's Avatar

    ah - yeah we'd be looking for the structure that goes with the stable
    offline version. The goal is to have our fire-season setup working without
    any internet. Anyway the json that I'm currently sending is basically what
    the network traffic monitor shows in the previous tab - but the marker
    label can't be changed after the marker is created. I'll try more
    combinations: using the json you mentioned with the online version, and
    using a closer match with what the offline version needs, to see if the
    can't-edit-label problem persists. In our application we'd want to be able
    to change the label after it is initially created to say the callsign of
    the officer(s) at that address if any, which will change over time.

  7. Support Staff 7 Posted by matt on 13 Jul, 2018 03:42 AM

    matt's Avatar

    In that case try setting the marker url to "#FF0000" or some other color, rather than leaving it blank.

  8. Support Staff 8 Posted by caver456 on 13 Jul, 2018 12:59 PM

    caver456's Avatar

    perfect, that did the trick. Leaving URL blank results in a marker whose
    label cannot be changed.

    Two follow-on bigger questions:

    - have you considered publicizing/formalizing the API so folks can develop
    their own 'middleware' as the King County folks mentioned? No doubt there
    is a can of worms that I am not familar with, but, the fact that caltopo is
    extensible and has an API like this is a pretty huge selling point in my
    opinion.

    - have you considered creating a central web page or such showcasing the
    'middleware' that various folks have written? There would be some things
    to figure out there too, but, again, it would be a pretty huge selling
    point. We've got three entries of our own we would add (radiolog,
    buckshot, and this offline address search thing) and it would be pretty
    nifty to see the others that are out there. In addition to the showcase
    selling points it could be a handy networking and collaboration tool for
    middleware developers and users to talk to each other without having to
    take up your time. If this sounds interesting, I could try to wrangle
    something up (on the clock or off, whichever seems appropriate).

  9. Support Staff 9 Posted by matt on 15 Jul, 2018 09:02 PM

    matt's Avatar

    At this point the API is not stable enough for me to want to publish details. It may be a nice selling point but it would also limit my ability to make quick changes. Soon, maybe - that was one of the reasons for switching to GeoJSON. Not sure there would be enough revenue gained to justify the time expense of documenting things though.

    I'm open to suggestions. Not something I have a plan for.

  10. Support Staff 10 Posted by caver456 on 16 Jul, 2018 05:19 PM

    caver456's Avatar

    One api suggestion / feature request is a zoom-to-coordinates or
    zoom-to-object call or some other method of zooming to a data object
    without the object's popup opening in the map.

    Regarding the showcasing of 3rd party apps, do you know if there are any
    caltopo or sartopo users groups already in existence? I could contact them
    with the idea to keep it out of your hair.

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:

»

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac