Android Question Mapview: convert ECW format

AlpVir

Well-Known Member
Licensed User
Longtime User
MapView uses several small PNG images (256x256 pixel I think) placed in a folder structure whose name I can not understand.
There are various levels
0) root
1) osmdroid
2) tiles
3) Mapnik or other source
4) Zoom
5) 4-digit numbers whose meaning I do not understand
6) PNG files with extension "png.tile" (also in this case do not understand the meaning of the names of the files)

Because I want to create (in VB6) a format converter from ECW format used for MapView I would have a bit 'of information about:
a) size of the individual images
b) an explanation about the folder structure.
Probably a link to a specific site could be enough, I have not been able to find it.

And if there was a program (such as Global Mapper) that already does this conversion would be all the better.

Thanks in advance.
 

AlpVir

Well-Known Member
Licensed User
Longtime User
Upvote 0

warwound

Expert
Licensed User
Longtime User
I'd never heard of the ECW format but had a Google and found what it is.

Are you looking for a 'tile cutter' application, an application that takes a single large image and converts it into tiles?
I found no tile cutter applications when i needed one so wrote my own - i wrote it using java not b4a or b4j, though with a little time and effort it could be re-written using b4j.

My application is attached if you want to give it a try, it's a command line utility, a typical command would be:

B4X:
java -jar SlippyTileCutter.jar C:\tmp\SlippyTileCutter\map_of_the_uk.jpg C:\tmp\SlippyTileCutter\tiles\ jpg

The application is launched using java -jar SlippyTileCutter.jar, and it has three command line parameters:
  • C:\tmp\SlippyTileCutter\map_of_the_uk.jpg
    This is the path to the input file.
  • C:\tmp\SlippyTileCutter\tiles\
    This is the path to save the created tiles to, note that it must include a trailing slash.
  • jpg
    This is the format to save the tiles in, valid options are 'gif', 'jpg' and 'png'.

The application though i'm sure won't be able to open an ECW format image.
Can you convert these ECW format images to a format that the application does support?
(By default the application supports gif, png, jpg, bmp and wbmp format input images).

My application is far from complete - it can create tiles using various different algorithm from quick low quality to slow high quality.
It's hardcoded to a 'balanced' quality setting.
My ulitimate goal was to get the command line application working then build a GUI around it - so far i've not had time to do that.
The background padding color is also hardcoded to black - again the plan was/is to make such settings configurable.

Have a look and if you think my application could be useful let me know and i'll update it to make all settings configurable.

Martin.
 

Attachments

  • SlippyTileCutter.zip
    481.5 KB · Views: 240
Upvote 0

M6SOFT

Member
Licensed User
Longtime User
I worked last time on something similar. Take a look at this app
This is written in delphi and probably it can generate tiles from ecw.
If ecw do not have defined coordinate system You can add it: simply doubleclick on layer name and go to the section "Layer".
Only layers with defined coordinate system can be exported to tiles.
 
Upvote 0

AlpVir

Well-Known Member
Licensed User
Longtime User
@warwound
The ECW files are the best you can think about maps.
For example I have a map of 100000x133000 pixels - 3.6 GB - 2.5 m/pixel - WGS84 - 251x332 Km

I converted a small map ECW (45 MB) to jpg (29 MB - 15200x6900 pixels) and then I launched your program but I get this error
G:\Temp4\SlippyTileCutter>java -jar SlippyTileCutter.jar G:\Temp4\SlippyTileCutter\v.jpg G:\Temp4\SlippyTileCutter\tiles\ jpg
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
at java.awt.image.DataBufferByte.<init>(Unknown Source)
at java.awt.image.ComponentSampleModel.createDataBuffer(Unknown Source)
at java.awt.image.Raster.createWritableRaster(Unknown Source)
at javax.imageio.ImageTypeSpecifier.createBufferedImage(Unknown Source)
at javax.imageio.ImageReader.getDestination(Unknown Source)
at com.sun.imageio.plugins.jpeg.JPEGImageReader.readInternal(Unknown Source)
at com.sun.imageio.plugins.jpeg.JPEGImageReader.read(Unknown Source)
at javax.imageio.ImageIO.read(Unknown Source)
at javax.imageio.ImageIO.read(Unknown Source)
at uk.co.martinpearman.java.slippytilecutter.SlippyTileCutter.<init>(SlippyTileCutter.java:39)
at uk.co.martinpearman.java.slippytilecutter.SlippyTileCutter.main(SlippyTileCutter.java:24)
But I do not understand how your program can maintain georeferencing that is lost in the transition to jpg.
Perhaps through a file JPW ?
Do you have experience with Global Mapper ?
It may be able to divide a map ECW in tiles, maintaining georeferencing.

@M6SOFT
An error message appears (File can't be open 0031 Error during reading file NCSEcw4_RO.dll - code 0)
In my projects (language VB6) I use for the maps ECW:
NCSAddOn.dll
NCScnet.dll
NCSEcw.dll
NCSVer.dll
NCSView.dll
NCSUtil.dll
 
Upvote 0

AlpVir

Well-Known Member
Licensed User
Longtime User
Tanks
With the SDK libraries your program works, it will create any folders for each zoom factor, but the result is not satisfactory.
See attached picture with the main picture (scale 1:1) and two tile (zoom zoom 15 and 14).
The originale ECW file is 15200x6973 pixel - 3.2 m/pixel - 48.26x22.139 Km - 45 MB
 

Attachments

  • OZ15.jpg
    OZ15.jpg
    217.2 KB · Views: 342
Upvote 0

M6SOFT

Member
Licensed User
Longtime User
You are right, it's far from perfect. I haven't experience with ECW. If You want i can take a look at sources how to improve quality.
 
Upvote 0

AlpVir

Well-Known Member
Licensed User
Longtime User
As you may have noticed at zoom 15 there is a reduction of 91%.
He should be a nothing reduction (or scale 1:1).
The best solution would be to have a library that manages the files ECW.
TwoNav (http://en.compegps.com/products/software/twonav/) manages the RMAP files that are a direct derivation of the ECW files.
Do you have any experience on this?
 
Upvote 0

AlpVir

Well-Known Member
Licensed User
Longtime User
Thank you for your interest.
I hope I can explain my bad english
It 'clear that at zoom 15 images are of poor quality.
This is due to the fact (to me) that the reduction algorithm is ... inefficient.
I did this test:
1) I have taken (with print screen) a square of 281x281 pixels to be displayed with a map ECW zooom 100%
Note that 256/0.91 = 281
2) I have reduced the square with Photoshop 281x281 to 256x256
3) the result is excellent, satisfactory (See attached file)

From the link I've provided is (for zoom = 15) a value of 4.773 m/pixels while the ECW map of my example is 3.2 m/pixel. It 'should therefore be reduced and this reduction is not of good quality.

As soon as I can I will try to see if I can get a better result with VB6
 
Upvote 0
Top