How to refresh shape layer programmatically when underlying shape file have been updated

56 views
Skip to first unread message

Руслан Сорокин

unread,
Dec 4, 2019, 8:58:17 AM12/4/19
to openmap-users
Dear openmap users and team (Don)!

How to refresh shape layer programmatically when underlying shape file have been updated on disk.
Thanks in advance.

Sincerely,
  Ru

Don Dietrick

unread,
Dec 4, 2019, 3:23:38 PM12/4/19
to Руслан Сорокин, openmap-users
Hi Ru!

You should be able to call setSpatialIndex(newSpatialIndex) on the layer, and then doPrepare().  You can create a new SpatialIndex using the static method locateAndSetShapeData(path to shape file).

This should work for the regular ShapeLayer and BufferedShapeLayer.

Hope this helps,

Don

--
You received this message because you are subscribed to the Google Groups "openmap-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openmap-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/openmap-users/fb80e0e2-d9df-458a-a9c5-0505c09c600a%40googlegroups.com.

Руслан Сорокин

unread,
Dec 5, 2019, 4:38:33 AM12/5/19
to openmap-users
Hi Don!

If a spatial index file already exists, does the approach is the same? As I understand from API doc, locateAndSetShapeData method will attempt to build the spatial index file and place it next to the shape file every time when I call my refresh method. This is not very efficient, is not it? External program  itself creates updated version of the spatial index file every time when it creates updated version of the shape file.
Here I try to create some animation :)

Sincerely,
  Ru

среда, 4 декабря 2019 г., 23:23:38 UTC+3 пользователь Don Dietrick написал:
Hi Ru!

You should be able to call setSpatialIndex(newSpatialIndex) on the layer, and then doPrepare().  You can create a new SpatialIndex using the static method locateAndSetShapeData(path to shape file).

This should work for the regular ShapeLayer and BufferedShapeLayer.

Hope this helps,

Don

On Dec 4, 2019, at 8:58 AM, Руслан Сорокин <sor...@oogis.ru> wrote:

Dear openmap users and team (Don)!

How to refresh shape layer programmatically when underlying shape file have been updated on disk.
Thanks in advance.

Sincerely,
  Ru


--
You received this message because you are subscribed to the Google Groups "openmap-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openma...@googlegroups.com.

Don Dietrick

unread,
Dec 9, 2019, 4:44:58 PM12/9/19
to Руслан Сорокин, openmap-users
Hi Ru,

If the locations of map features in your shp file are changing, you’ll need to generate a new spatial index file and load that - it contains bounding boxes and relates those to indexes of objects in the shape file.   It’s probably not that efficient.  But the ShapeLayer only uses that file to figure out what parts of the shp file that are actually on the map at a particular projection, so if you’re using everything in the shp file you don’t really need it - you can easily put together code to use the ShapeFile to just read the file and create OMGraphics.

What’s your update rate is and how much data you are reloading?  Do you need to load the dbf file to get attribute information for each of your map features? Is the number or order of map features in the shp file changing?

Do you have control over the external program and the data it gives you?  There are easier/faster ways to do animation, especially if the updates are quite rapid.  But if you have to use shape files, there are several things you can do to make it efficient, depending on what other requirements you have to consider.

Cheers,

Don

To unsubscribe from this group and stop receiving emails from it, send an email to openmap-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/openmap-users/55bbcaf7-1a77-46ec-8c8b-6564ed34f590%40googlegroups.com.

Руслан Сорокин

unread,
Dec 24, 2019, 9:57:59 AM12/24/19
to openmap-users
For now I satisfied with the simple solution you proposed. If you interested, this is a screencast of example: https://www.youtube.com/watch?v=Snd3VKUevNg&feature=youtu.be

Sincerely,
  Ru

вторник, 10 декабря 2019 г., 0:44:58 UTC+3 пользователь Don Dietrick написал:

Руслан Сорокин

unread,
Dec 24, 2019, 9:59:04 AM12/24/19
to openmap-users
Thank you very much :)

вторник, 24 декабря 2019 г., 17:57:59 UTC+3 пользователь Руслан Сорокин написал:
Reply all
Reply to author
Forward
0 new messages