[Gvsig_english] Code Question - raster layers

Aldo Stracquadanio aldo.strac at gmail.com
Fri Sep 18 09:44:13 CEST 2009


Hello Juan,

Thank you very much for the hints! The ecw format is working fine; it
has faster loading and redrawing than jpg/png too. As for my
application I need only a small piece from the city, since it will be
a simple tourist applet, with the correct referencing for GPS, street
names, paths and "points of interest". So I don't know if I will write
an OSM driver; however in case I will do something useful for gvSIG
Mobile I'll eventually send you the code.

Regards,
Aldo Stracquadanio.

2009/9/17 Juan Lucas Dominguez Rubio <jldominguez at prodevelop.es>:
> Hello, Aldo:
>
> Yes, you should pay for the J9 license if you are going to use it in a
> commercial application.
>
> In the OpenStreetMap tiles, the north is always the upper margin, so there
> should be no need to rotate an image composed with those tiles.
>
> If you use those tiles, changing the projection to EPSG:4326 causes the
> labels to become almost unreadable. I would use EPSG:32633 which is also
> known by gvSIG Mobile.
>
> I suggest to do the following:
>
> - Download several OSM tiles.
> - Merge all the tiles in one image and compute the mercator coordinates of
> the top-left corner and the pixel width.
> - Write the WLD file and reproject the resulting image to EPSG:4326 or
> EPSG:32633, then convert it to the ECW format, so you can use in gvSIG
> Mobile.
>
> I have done this with the city of Catania. You can download its OSM map (z =
> 15) in ECW format (EPSG:4326 and EPSG:32633) from this link:
>
> http://www.prodevelop.es/files/fm/public/downloads/documents/catania_osm_ecw.zip
>
> You could also add support for the projection used by OSM so you don't need
> to reproject the tiles. This would be very easy because the formulas are
> already implemented in the code, you only need to use them.
>
>
> Regards,
>
> Juan Lucas Domínguez Rubio
> ---
> Prodevelop SL, Valencia (España)
> 0° 22' 49.62" W, 39° 28' 25.45" N
> Tlf.: 96.351.06.12 -- Fax: 96.351.09.68
> http://www.prodevelop.es
> ---
> ________________________________
> De: gvsig_internacional-bounces at listserv.gva.es en nombre de Aldo
> Stracquadanio
> Enviado el: jue 17/09/2009 9:24
> Para: Users and Developers mailing list
> Asunto: Re: [Gvsig_english] Code Question - raster layers
>
> Thank you for these advices,
>
> I will try to put them in practice soon; just for completeness I'm
> sending you the gvm project that is causing me troubles. If I'll write
> some code to deal with transforms of jpg/gif/png images I'll send it
> too. However I don't think I will be able to use IBM J9 in production
> environment, since if I'm not wrong it should be protected by licences
> and we should pay to use it in a commercial application.
>
> Regards,
> Aldo Stracquadanio.
>
> 2009/9/16 Juan Lucas Dominguez Rubio <jldominguez at prodevelop.es>:
>> Hello, Aldo.
>>
>> Yes, we know that the VM sometimes (I think J9 doesn't) uses a new thread
>> when dealing with images (reading or resampling), that's why we wrote this
>> method:
>>
>> public static Image getScaled(Image img, int newwidth, int newheight);
>>
>> in the ResourceReader class, but I think we forgot to use it in the draw
>> method of the WKFRasterDriver class :-/
>>
>> So I think you have these three options:
>>
>> - Use the J9 version (as I said, I think J9 loads/resamples images in the
>> main thread)
>> - Edit the code, use that method and compile
>> - Convert your JPG/PNG/GIF images to ECW with Gdal (
>> http://fwtools.maptools.org )
>>
>> Even if you use J9 or fix the bug yourself, I recommend using ECW because
>> the other formats are a great bother. After loading one of those images,
>> the
>> application becomes more unstable.
>>
>> Thanks for reporting this problem.
>>
>> As for the rotation, we simply ignore it. The second and third parameters
>> of
>> the world file (*.WLD) are not used at all, sorry. Again, with Gdal you
>> can
>> convert a rotated image (PNG/JPG/GIF + WLD file with non-zero values in
>> second and third line) into a ECW file which will obviously have black
>> triangles by the margins. In this case, you need two steps:
>>
>> gdalwarp image.jpg image.tif
>> gdal_translate -of ecw image.tif image.ecw
>>
>>
>>
>> Regards,
>>
>> Juan Lucas Domínguez Rubio
>> ---
>> Prodevelop SL, Valencia (España)
>> 0° 22' 49.62" W, 39° 28' 25.45" N
>> Tlf.: 96.351.06.12 -- Fax: 96.351.09.68
>> http://www.prodevelop.es
>> ---
>> ________________________________
>> De: gvsig_internacional-bounces at listserv.gva.es en nombre de Aldo
>> Stracquadanio
>> Enviado el: mié 16/09/2009 13:00
>> Para: Users and Developers mailing list
>> Asunto: Re: [Gvsig_english] Code Question - raster layers
>>
>> Hi Juan,
>>
>> I know about the limitation of 400k pixels, I will send you the
>> exported project I'm working on as soon as I will be in my office. The
>> problem with resampling of the image is that a
>> clipping-translating-composition can't resolve the rotation part of a
>> generic affine transform (and I think in my image it's needed a little
>> rotation too).
>>
>> Moreover I see that you use the getScaledInstance method to get a
>> scaled instance of the image and immediatly after this you check for
>> width. This often gives me -1 (causing an exception) because this
>> method (like the most of the graphics methods of CDC) can exibit an
>> asynchronus behavior; have you ever had such problems?
>>
>> Regards,
>> Aldo Stracquadanio.
>>
>> 2009/9/15 Juan Lucas Dominguez Rubio <jldominguez at prodevelop.es>:
>>> Hello, Aldo.
>>>
>>> As you say, the Graphics2D class in CDC knows nothing about affine
>>> transforms, so you always have to provide 'final' coordinates, that is,
>>> screen coordinates.
>>>
>>> The Image class has a resample method and of course there are ways to
>>> clip
>>> an image, so all you have to do is clipping and resizing the image until
>>> you
>>> have the final image, and then paste it in the correct coordinates on the
>>> screen, that's what the WKRasterDriver does.
>>>
>>> These images (we're talking about JPG, PNG and GIF images; the ECW driver
>>> is
>>> totally different) are very memory-consuming and can only be loaded if
>>> the
>>> have less than 400,000 pixels. If we tried to open larger images, the
>>> virtual machine itself would be at risk.
>>>
>>> We tried to do the clipping and resampling in such a way that we never
>>> need
>>> to instantiate a large image, but maybe this is not always possible.
>>>
>>> Can you send us the log files under \gvSIGMobile\log\ or even the image
>>> itself?
>>>
>>>
>>> Regards,
>>> Juan Lucas Domínguez Rubio
>>> ---
>>> Prodevelop SL, Valencia (España)
>>> 0° 22' 49.62" W, 39° 28' 25.45" N
>>> Tlf.: 96.351.06.12 -- Fax: 96.351.09.68
>>> http://www.prodevelop.es
>>> ---
>>>
>>>
>>>
>>> -----Mensaje original-----
>>> De: gvsig_internacional-bounces at listserv.gva.es en nombre de Aldo
>>> Stracquadanio
>>> Enviado el: mar 15/09/2009 18:32
>>> Para: gvsig_internacional at listserv.gva.es
>>> Asunto: [Gvsig_english] Code Question - raster layers
>>>
>>> Hi everybody,
>>>
>>> I'm reading the phoneME Mobile source code, but I can't understand
>>> something about the WKFRasterDriver: if there is no support for
>>> AffineTransform in CDC, how do you obtain a "shear" effect using only
>>> scaling-translation operations? I can't figure it out and, as well,
>>> the raster layer visualization is not working at all on my
>>> installation: in my opinion there is some problem with the asynchronus
>>> behaviour of the Image.getScaledInstance method since I get a "Cannot
>>> resample (down)".
>>>
>>> Can someone help me understanding?
>>> Thank's all, Aldo Stracquadanio.
>>> _______________________________________________
>>> Gvsig_internacional mailing list
>>> Gvsig_internacional at listserv.gva.es
>>> http://listserv.gva.es/cgi-bin/mailman/listinfo/gvsig_internacional
>>>
>>>
>>> _______________________________________________
>>> Gvsig_internacional mailing list
>>> Gvsig_internacional at listserv.gva.es
>>> http://listserv.gva.es/cgi-bin/mailman/listinfo/gvsig_internacional
>>>
>>>
>> _______________________________________________
>> Gvsig_internacional mailing list
>> Gvsig_internacional at listserv.gva.es
>> http://listserv.gva.es/cgi-bin/mailman/listinfo/gvsig_internacional
>>
>> _______________________________________________
>> Gvsig_internacional mailing list
>> Gvsig_internacional at listserv.gva.es
>> http://listserv.gva.es/cgi-bin/mailman/listinfo/gvsig_internacional
>>
>>
>
> _______________________________________________
> Gvsig_internacional mailing list
> Gvsig_internacional at listserv.gva.es
> http://listserv.gva.es/cgi-bin/mailman/listinfo/gvsig_internacional
>
>


More information about the Gvsig_internacional mailing list