mapscript + inline features

Umberto Nicoletti umberto.nicoletti at GMAIL.COM
Thu Jul 6 04:51:13 PDT 2006


I have tried to run your example and got this output:

can't open layer
num res: 1
shp 0: -1

Since the layer can't be opened there is no point in trying to fetch
query results from it.

Digging more into the code reveals that INLINE layers have a default
implementation of the getItems funtion that only returns ms_failure
(see maplayer.c).

Regards,
Umberto

On 6/29/06, listuser HH <listuser at herzsys.de> wrote:
> Hi all,
>
> i'm using java mapscript from ms4w and i try to query a layer with
> inline feature (no direct data source).
>
> I get the correct count of results from a querybyrect but i can't get
> the feature and it's values. This is because the resultCacheObj has an
> index of -1. So it is not possible to use the getFeature. The getFeature
> works for the inline features if i use a possible index like 0.
>
> Any hint / solution?
>
> Best regards
>
> Norbert
>
>
> *****************************************************************
>
> -----------------
>       test.java
> -----------------
>
> public class InlineFeatureTest {
>
>     public static void main(String[] args) {
>         URL mapURL = InlineFeatureTest.class.getResource("/test/test.map");
>         StringBuffer sb = new StringBuffer(mapURL.getFile());
>         sb.deleteCharAt(0);
>         mapObj map = new mapObj(sb.toString());
>         layerObj layer = map.getLayerByName("inline");
>         if (layer == null) return;
>
>
>         shapeObj shape = new
> shapeObj(MS_SHAPE_TYPE.MS_SHAPE_POINT.swigValue());
>         lineObj line = new lineObj();
>         boolean error = false;
>         if (line.add(new pointObj(3500000, 5500000, 0)) ==
> MS_RETURN_VALUE.MS_FAILURE.swigValue()) error  = true;
>         if (shape.add(line) == MS_RETURN_VALUE.MS_FAILURE.swigValue())
> error = true;
>         shape.setValue(0, "test1");
>         shape.setValue(1, "test2");
>         shape.setValue(2, "test3");
>         if (layer.addFeature(shape) ==
> MS_RETURN_VALUE.MS_FAILURE.swigValue()) error = true;
>
>         if (error) System.out.println("can't add point");
>
>         map.queryByRect(new rectObj(3400000, 5400000, 3600000, 5600000, 0));
>
>         int numRes = layer.getNumResults();
>         resultCacheObj infoResults = null;
>
>         if (layer.open() == MS_RETURN_VALUE.MS_FAILURE.swigValue())
> System.out.println("can't open layer");
>
>         System.out.println("num res: " + numRes);
>
>         if (numRes > 0) {
>             infoResults = layer.getResults();
>             for (int resNr = 0; resNr < numRes; resNr++){
>                 resultCacheMemberObj resObj = infoResults.getResult(resNr);
>
>                 int shpIndex = resObj.getShapeindex();
>                 System.out.println("shp " + resNr + ": " + shpIndex);
>
>                 if (shpIndex >= 0) {
>                     shapeObj tmpFeature = layer.getFeature(shpIndex, -1);
>                     System.out.println("num values = " +
> tmpFeature.getNumvalues());
>                 }
>             }
>         }
>     }
>
> }
>
>
> ---------------------
>    test.map
> ---------------------
> MAP
>   EXTENT 3565000 5630000 3570000 5680000
>   IMAGECOLOR 255 255 255
>   IMAGETYPE png
>   SIZE 500 500
>   STATUS ON
>   UNITS METERS
>   NAME "MS"
>
>   OUTPUTFORMAT
>     NAME "PNG"
>     MIMETYPE "image/png"
>     DRIVER "GD/PNG"
>     EXTENSION "png"
>     IMAGEMODE "PC256"
>     TRANSPARENT FALSE
>   END
>
> SYMBOL
>   NAME "circle"
>   TYPE ELLIPSE
>   POINTS
>     1 1
>   END
>   FILLED TRUE
> END
>
>   PROJECTION
>     "init=epsg:31467"
>   END
>
>   QUERYMAP
>     COLOR 255 255 0
>     SIZE -1 -1
>     STATUS OFF
>     STYLE HILITE
>   END
>
>   WEB
>     IMAGEPATH "../temp/"
>     IMAGEURL "./mapserver/temp/"
>   END
>
>   LAYER
>     NAME "inline"
>     PROJECTION
>       "init=epsg:31467"
>     END
>     SIZEUNITS PIXELS
>     STATUS DEFAULT
>     TOLERANCEUNITS PIXELS
>     UNITS METERS
>     TYPE POINT
>     TEMPLATE "dummy"
>
>     CLASS
>       METADATA
>       END
>       STYLE
>         ANGLE 360
>         COLOR 255 0 0
>         SYMBOL "circle"
>         SIZE 10
>       END
>     END
>   END
>
> END
>



More information about the MapServer-users mailing list