MapSuite Team,
I have a street layer that is used for both rendering on the map and also to use for reverse geo-code based on Lat/Long.
My application receives a request to center the map at a given Lat/Long. Once the Center is invoked the application then receives multiple requests to perform reverse geo-code lookup based on other Lat/Long combinations.
What occurs is that the rendered streets on the map display begin to disappear and the reverse geo-code lookup returns no results.
So while the streets are being rendered in the background MapSuite threads the additional reverse geo-code requests come in while the streets are still being rendered.
I suspect my issue has something to do with how the ShapeFileFeatureLayer is opened. When a request is made for reverse geo-code the first thing done is to see if the layer is opened. If not open then it is opened and left opened.
What do you think?
Regards,
Dennis
ShapeFileFeatureLayer Query Causes Layer to Disappear
Hi Dennis,
Do you think your problem is caused by the render logic conflict with query logic?
I think for solve that, you can try these solutions:
1. Open tile cache for render logic, so it won’t read shape file but only read cached tile.
2. You can keep your shape file “Open”, just close it when you remove the layer from your map.
3. Why not have a copy of currently shape file, one for render and one for query.
In fact, I am not sure how you call reverse geocode, are you using our Geocode product or just use spatial query on shape file and get its column values? If you are choose the spatial query, I don’t think it have thread conflict, so if possible please let us know more detail about your code.
Regard,
Don
Don,
Yes, I believe there is some conflict between rendering and the spatial query.
I make use of QueryTools.GetFeaturesNearestTo to perform a spatial query then do a DeepClone on the returned features to determine closet address.
Initially I had it coded in the spatial query logic such that if the layer was not open it would open it, do the spatial query and then close it. In this case the streets on the map would eventually disappear.
My current code opens the layer if not already opened, do the spatial query, but never close the layer just leave it open. In this case both the streets disappear from the map and the spatial queries eventually fail to return results.
Should the layer be opened in ReadOnly Mode or in ReadWrite Mode? I open all layers as ReadOnly as my application does not modify the shape files.
I had considered opening a second ShapeFileFeatureLayer for the streets layer, but since I already have some 70 layers I was afraid to use any more memory.
Any thoughts you might have?
Thanks,
Dennis
Hi Dennis,
By default, the Map Suite opens the shapefile with readonly if the property “ReadWriteMode” is not changed from the application.
For reproduced your problem, I build a simple sample as below, please view it and modify it if I missed anything.
Regards,
Don
Getting_Started.zip (1.43 KB)
Don,
The code in your example is, in essence, the same as what I have coded. This issue will most likely never surface in your example because you are only drawing one layer. My application, when it centers on a Lat/Long, is drawing around 40 layers, plus there are GPS update messages coming in at the rate of 30+ per second.
The issue here is not one of code, per se, but of the interference of the drawing of the layers with the QueryTools.GetFeaturesNearestTo method. Before the drawing of the layers is complete, on the background threads, my application invokes the GetFeaturesNearestTo. So the drawing of the layers is being performed on the MapSuite background threads while the GetFeaturesNearestTo is on the UI thread.
Dennis
hi Don,
Were you able to figure out what the issue is with this? This is a critical issue for me and really need to find a solution.
Regards,
Dennis
Hi Dennis,
Sorry I am not work for support yesterday.
I think I find why the shape disappear, that’s because you refresh too fast, and there are so many shape files need to be render, the I/O speed cannot follow the refresh speed.
Please see my attached sample, it won’t draw shape succeed, but the spatial query looks works well. If that reproduced what you met, then the problem is not the conflict between render and query.
I think you have to change your strategy for avoid that.
1. Reduce I/O request, try to use tile cache instead of directly render from shape file.
2. Use InmemoryFeatureLayer but not ShapeFileFeatureLayer. But you mentioned you won’t use more memory, so ignore this.
3. Don’t refresh whole map when you get new GPS Point, unless this new point is not in current extent.
Wish that’s helpful.
Regards,
Don
12533-2.zip (1.72 KB)
Hi Dennis,
Sorry I am not work for support yesterday.
I think I find why the shape disappear, that’s because you refresh too fast, and there are so many shape files need to be render, the I/O speed cannot follow the refresh speed.
Please see my attached sample, it won’t draw shape succeed, but the spatial query looks works well. If that reproduced what you met, then the problem is not the conflict between render and query.
I think you have to change your strategy for avoid that.
1. Reduce I/O request, try to use tile cache instead of directly render from shape file.
2. Use InmemoryFeatureLayer but not ShapeFileFeatureLayer. But you mentioned you won’t use more memory, so ignore this.
3. Don’t refresh whole map when you get new GPS Point, unless this new point is not in current extent.
Wish that’s helpful.
Regards,
Don
12533-2.zip (1.72 KB)
Don,
I’m now loading my streets layer as a GeoCache and that has greatly improved the situation.
I’m still not understanding why two different threads cannot read the same shape file at the same time. Seems like it should support that.
Thanks,
Dennis
Hi Dennis,
I am glad to hear open cache improve the enhancement.
In fact we support different threads read same shape file, this issue seems it not enough fast when map keep refresh. So I think that’s caused by disk read speed not enough.
Regards,
Don