Hi,
I will try to create a small demo programm in next few days, in the meantime I
found that my solution needed a little tweak:
jMapPane.addMapPaneListener(new MapPaneAdapter() {
@Override
public void onRenderingStopped(MapPaneEvent arg0) {
try {
Thread.sleep(500);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
jMapPane.repaint();
}
});
Again: no idea why it helps :-)
Alex
Von: Jody Garnett [mailto:[email protected]]
Gesendet: Donnerstag, 9. Juni 2011 04:44
An: [email protected]
Cc: [email protected]
Betreff: Re: [Geotools-gt2-users] osm tiles: GridCoverage2D layers
You should report this as a Jira issue then; is there any way for you to create
a small java program showing the problem (it really helps when reporting issues
if the volunteer does not have to try and sort out how to test for the problem).
--
Jody Garnett
On Thursday, 9 June 2011 at 12:12 PM, Alexander Lanin wrote:
Oh sry, fount the tile code in 2.5. Unfortunately the GridCoverage2D creation
is identical and there is nothing there beyond that.
Alex
-----Ursprüngliche Nachricht-----
Von: Alexander Lanin [mailto:[email protected]]
Gesendet: Donnerstag, 9. Juni 2011 03:54
An: [email protected]
Betreff: Re: [Geotools-gt2-users] osm tiles: GridCoverage2D layers
Hi,
Thanks for your reply. That’s actually what I’m going for. I have a Cache that
holds some thousand tiles in ram and a cache that uses the hard drive. Using a
simple HashMap respectively file names for that. I have a Listener, maybe a
MapPaneListener, that will download tiles in a separate thread and render them
as required.
Back to the missing tiles:
I was able to eliminate the problem in 2 ways:
map.setRepaint(false);
add all layers
map.setRepaint(true);
map.drawBaseImage(false); // I made this public
map.repaint();
But since adding all layers may take several seconds that isn’t really
acceptable. Interesting enough I found another solution:
After adding each layer as described before I add a sleep:
map.getMapContext().addLayer(layer);
Thread.sleep(25);
Then I can see how tile by tile is drawn - and it flickers a LOT :D
But at least the final result is perfect. It’s just not advisable to look at it
during rendering…
I can only guess the Problem is something like addLayer triggering
drawBaseImage or something multiple times before the last run was even
completed.
“We did back port the tile code in GeoTools 2.5.x” can u please point me to
where that is? I downloaded 2.5.8-src but can’t find it there.
“I expect you are running into trouble with images being loaded gradually” –
during testing I have all the BufferedImages in ram.
Regards,
Alex
P.S. sry code in last mail lost all line breaks, no idea why that happened.
Von: Jody Garnett [mailto:[email protected]]
Gesendet: Donnerstag, 9. Juni 2011 02:04
An: [email protected]
Cc: [email protected]
Betreff: Re: [Geotools-gt2-users] osm tiles: GridCoverage2D layers
We do something similar to display tiles from a range of services (google maps,
osm, wmts, etc...) in uDig. We gather up the tiles into a collection of grid
coverages for display. We do however load the tiles in a background thread and
refresh the screen as they come in (with the option of loading them into a
memory or disk based cache).
I expect you are running into trouble with images being loaded gradually; and
your mapMove gives you a chance to redraw the same image now that it has
content. You may wish to try and force the content to load (and listen to the
image so you can tell when it is done); or save the content to disk and render
from that ...
We did back port the tile code in GeoTools 2.5.x but there was not enough
enough collaboration to complete the effort. Since that time a google summer of
code project has made the uDig tile rendering / fetching system much more
capable. If anyone is interested in porting the work into an unsupported module
is welcome to, the uDig code base would happily track the change to prevent
duplication of future effort.
--
Jody Garnett
On Thursday, 9 June 2011 at 9:10 AM, Alexander Lanin wrote:
Hi,
I'm trying to get osm tiles (256x256px images) to display in my JMapPane.
What I do is: I download tiles from http://tile.openstreetmap.org/ (then I
cache etc.) and then:
StyleBuilder sb = new StyleBuilder();
Style style = sb.createStyle(sb.createRasterSymbolizer());
GridCoverageFactory gridFactory = new GridCoverageFactory(); GridCoverage2D
grid = gridFactory.create("GridCoverage-" + tile.getUniqueId(),
tile.getImage(), tile.getEnvelope()); MapLayer layer = new MapLayer(grid,
style); _map.getMapContext().addLayer(layer);
_map.repaint();
With _map being a JMapPane.
While this works most of the time, some tiles/layers are sometimes not
rendered. Actually every time there are some tiles/layers missing.
Interestingly when using JMapPane.moveImage in a completely unrelated part
of my code (panning) all the tiles show up. I already tried to use
moveImage(1,1) after addLayer, but that just messes everything up.
Sometimes I get this message:
09.06.2011 00:09:30
org.geotools.renderer.lite.gridcoverage2d.GridCoverageRenderer
prepareFinalImage
INFO: The destination envelope does not intersect the envelope of the source
coverage.
But that's just 10% of the time tiles/layers are missing.
Am I even on the right track for displaying these images? And why doesn't it
work? :-)
Oh and I'm using geotools 8.0-M.0 + fix from
http://jira.codehaus.org/browse/GEOT-3555
Regards,
Alex
------------------------------------------------------------------------------
EditLive Enterprise is the world's most technically advanced content
authoring tool. Experience the power of Track Changes, Inline Image
Editing and ensure content is compliant with Accessibility Checking.
http://p.sf.net/sfu/ephox-dev2dev
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
------------------------------------------------------------------------------
EditLive Enterprise is the world's most technically advanced content
authoring tool. Experience the power of Track Changes, Inline Image
Editing and ensure content is compliant with Accessibility Checking.
http://p.sf.net/sfu/ephox-dev2dev
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
------------------------------------------------------------------------------
EditLive Enterprise is the world's most technically advanced content
authoring tool. Experience the power of Track Changes, Inline Image
Editing and ensure content is compliant with Accessibility Checking.
http://p.sf.net/sfu/ephox-dev2dev
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
------------------------------------------------------------------------------
EditLive Enterprise is the world's most technically advanced content
authoring tool. Experience the power of Track Changes, Inline Image
Editing and ensure content is compliant with Accessibility Checking.
http://p.sf.net/sfu/ephox-dev2dev
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users