[mapserver-dev] Possible to use PostGIS as a TILEINDEX to shapefiles?

Brent Fraser bfraser at geoanalytic.com
Thu Apr 28 13:44:16 EDT 2011


Daniel,

   I hadn't considered that; thanks for the pointer.  But still no 
success...

I set up my LAYER definition as:

     LAYER
         NAME 'Landfast'
         TYPE LINE
         STATUS DEFAULT

         CONNECTIONTYPE OGR
         TILEINDEX "PG:dbname='PN2010_0911' host='thinkcentre1' 
port='5432' user='PN2010_0911' password='PN2010_0911'"
         DATA "select imageid, location_landfast, wkb_geometry from images"
         TILEITEM "location_landfast"

Running shp2img v6.0 beta4 results in:

msDrawMap(): Image handling error. Failed to draw layer named 
'Landfast'. <br>
msOGRFileOpen(): OGR error. ExecuteSQL(select imageid, 
location_landfast, wkb_geometry from images) failed.
SELECT from table images failed, no such table/featureclass. <br>

======================================

ogrinfo has no problem getting at the index:
G:\>ogrinfo -sql "select imageid, location_landfast, wkb_geometry from 
images" PG:"host='thinkcentre1' dbname='PN2010_0911' user='PN2010_0911' 
password='PN2010_0911'"
INFO: Open of `PG:host='thinkcentre1' dbname='PN2010_0911' 
user='PN2010_0911' password='PN2010_0911''
       using driver `PostgreSQL' successful.

Layer name: sql_statement
Geometry: Unknown (any)
Feature Count: 3
Extent: (-24.392027, 74.808823) - (-9.363171, 78.164185)
Layer SRS WKT:
(unknown)
Geometry Column = wkb_geometry
imageid: Integer (0.0)
location_landfast: String (250.0)
OGRFeature(sql_statement):0
   imageid (Integer) = 3
   location_landfast (String) = 
G:\GeoData\PN2010-0911\ice_edge\p230r005_20010703.shp
   POLYGON ((-20.789359999999999 77.004463200000004,-15.1615524 
76.001411399999995,-18.995115299999998 74.808822599999999,-24.3920269 
75.729690599999998,-20.789359999999999 77.004463200000004))

OGRFeature(sql_statement):1
   imageid (Integer) = 2
   location_landfast (String) = 
G:\GeoData\PN2010-0911\ice_edge\p230r005_20010703.shp
   POLYGON ((-19.2442856 77.004463200000004,-13.616478 
76.001411399999995,-17.4500408 74.808822599999999,-22.846952399999999 
75.729690599999998,-19.2442856 77.004463200000004))

OGRFeature(sql_statement):2
   imageid (Integer) = 1
   location_landfast (String) = 
G:\GeoData\PN2010-0911\ice_edge\p230r005_20010703.shp
   POLYGON ((-15.1506767 78.164184599999999,-9.3631706 
77.072578399999998,-13.8204384 75.943901100000005,-19.4379616 
76.942634600000005,-15.1506767 78.164184599999999))

Before I get too deep into a debug session, do you have an working 
example of a LAYER definition?

Best Regards,
Brent Fraser


On 4/28/2011 9:51 AM, Daniel Morissette wrote:
> I meant use CONNECTIONTYPE OGR for both the tileindex (OGR pointing to 
> your postgis tileindex table) and the shapefiles (connectiontype OGR 
> to read the shapefiles). This would not go through mapshape.c but 
> instead mapogr.cpp:
>
> http://mapserver.org/input/vector/ogr.html#tileindex-with-ogr
>
>
> On 11-04-28 10:34 AM, Brent Fraser wrote:
>> Daniel,
>>
>> Using OGR results in tlp->connectiontype==MS_OGR and fails as well.
>>
>> The main problem (I think) is that the code after line 1901 in
>> mapshape.c does a call to msDBFGetItemIndex in preparation for getting
>> the value stored in the "location" column. It needs to be replaced with
>> the code from mapraster.c, line 468:
>>
>> /* get the tileitem index */
>> for(i=0; i<tlp->numitems; i++) {
>> if(strcasecmp(tlp->items[i], layer->tileitem) == 0) {
>> tileitemindex = i;
>> break;
>> }
>> }
>>
>> and there could be a few other changes as well. I'll have to do some
>> hacking...
>>
>> Best Regards,
>> Brent Fraser
>>
>>
>> On 4/27/2011 9:02 PM, Daniel Morissette wrote:
>>> Unfortunately too late for 6.0 as you had already figured out. However
>>> you could use OGR connections for your PostGIS tileindex and to read
>>> your shapefiles with the current version.
>>>
>>> Daniel
>>>
>>>
>>> On 11-04-27 08:42 PM, Brent Fraser wrote:
>>>> I've used a PostGIS layer as a TILEINDEX to raster files, but it 
>>>> doesn't
>>>> seem to work for pointing to shapefiles.
>>>>
>>>> And looking at mapshape.c at line 1901 it checks:
>>>>
>>>> tlp = (GET_LAYER(layer->map, tSHP->tilelayerindex));
>>>>
>>>> if(tlp->connectiontype != MS_SHAPEFILE) {
>>>> msSetError(MS_SDEERR, "Tileindex layer must be a shapefile.",
>>>> "msTiledSHPOpenFile()");
>>>> return(MS_FAILURE);
>>>> }
>>>>
>>>>
>>>> mapraster.c has some logic around line 410 that seems more generic.
>>>>
>>>> I wonder if it would be possible to fix this for 6.0, or is it too 
>>>> late
>>>> now that rc1 is out?
>>>>
>>>
>>>
>>
>> _______________________________________________
>> mapserver-dev mailing list
>> mapserver-dev at lists.osgeo.org
>> http://lists.osgeo.org/mailman/listinfo/mapserver-dev
>
>



More information about the mapserver-dev mailing list