Basic example of using GDAL/OGR with MapViewer

This is a quick example of using gdal/ogr to access 3rd party spatial data formats in MapViewer. Specifically a MapInfo mid/mif and TAB files using the builtin ogrSDP (ogr spatial data provider class) to define and access a custom geometry theme.

First, download and install GDAL. I used the prebuilt binaries for version 1.9.2 for 64-bit Windows.

The precompiled supported formats list includes ESRI and MapInfo files
C:\Program Files\GDAL>ogrinfo --formats
Supported Formats:
  -> "ESRI Shapefile" (read/write)
  -> "MapInfo File" (read/write)
...

Then copy the gdal.jar file in the GDAL/Java directory over to someplace where it is in the classpath for MapViewer and MapBuilder. I copied it to the WEB-INF/lib directory for MapViewer and the directory which has MapBuilder.

Start up MapBuilder with gdal in the classpath and define custom geometry themes, i.e. use something like the following command to start it.
java -Xmx512M -cp .\mapbuilder.jar;.\gdal.jar oracle.mapviewer.builder.MapBuilder

Then define Custom Geometry Theme(s) using the ogrSDP. The following screenshots show the definition of a VICTORIA_TAB (tab file format) and MAPINFO_EXAMPLE (mid/mif format)  of postcode boundaries for someplace in Victoria, AU in the VicGrid94 spatial reference system. The corresponding SDO srid is 82473.

Once these are defined they can used as predefined themes in MapViewer. This assumes the files are accessible by the MapViewer server and the gdal.jar file is in the lib directory or in the classpath for that MapViewer server.

To test it, I modified the C00 - Display a predefined vector layer sample to use a different tile and vector layer. That is, the following lines of the sample code were changed to use the MAPINFO_EXAMPLE theme instead of "customers"
        var tileLayer = new OM.layer.TileLayer(
        "baseMap",
        {
            dataSource:"mvdemo",
            tileLayer:"elocation_map",
            tileServerURL: baseURL+"/mcserver"
        });
        map.addLayer(tileLayer) ;
        layer = new OM.layer.VectorLayer("layer1",
        {
            def:{
                type:OM.layer.VectorLayer.TYPE_PREDEFINED,
                dataSource:"mvdemo2", theme:"MAPINFO_EXAMPLE",
                url: baseURL
            }
        }); 
Re-running the modified sample gives the result shown in the screenshot below.







Comments:

Post a Comment:
  • HTML Syntax: NOT allowed
About

Official blog for Oracle FMW MapViewer and related products.

Search

Categories
Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today