[mapserver-users] java mapscript + postgis = query use pixel map's limits

Ludovico Bianchini metlud at yahoo.it
Mon Sep 29 16:19:46 EDT 2008


This is the code

LAYER
        NAME "segnaletica"
        STATUS on
        TYPE POINT
        TRANSFORM false
        POSTLABELCACHE true
        CONNECTION "user=user password=password dbname=dbname 
host=localhost port=5432"
        CONNECTIONTYPE postgis
        DATA "posizionegeoref from rilievi.impianti"
        CLASS
            STYLE
                COLOR 255 99 0
                SYMBOL "circle"
                SIZE 100
            END
        END
        PROJECTION
            "init=epsg:4326"
        END
    END

private void zoomIn(mapObj mapObj_o) {
        double[] extent = explodeExtent();//retrieve the previous map 
extent from the form data
        mapObj_o.setExtent(extent[0], extent[1], extent[2], 
extent[3]);//assign to the map the previous extent
        pointObj pointObj_o_pix = new 
pointObj(Integer.parseInt(getMap_x()),Integer.parseInt(getMap_y()), 
0);//create a pixel-based point for the user //click
        rectObj rectObj_o = new rectObj(extent[0], extent[1], extent[2], 
extent[3],
                mapscript.MS_FALSE);//create a rectangle based on the 
previous extent
        mapObj_o.zoomPoint(2, pointObj_o_pix, WIDTH, HEIGHT, rectObj_o, 
null);//zoom in the map; WIDTH=600 pixel, HEIGHT=400 pixel
       
        draw(mapObj_o);
    }

private void draw(mapObj mapObj_o){
            imageObj mapImageObj;
            String imageName = getImageName();
            String imagePath = IMAGE_URL + imageName;
            mapImageObj = mapObj_o.draw();
            mapImageObj.save(imagePath, mapObj_o);
            setMappa("/map/" + imageName);
            
setCurrent_extent(String.valueOf(mapObj_o.getExtent().getMinx()) + " " +
                    String.valueOf(mapObj_o.getExtent().getMiny()) + " " +
                    String.valueOf(mapObj_o.getExtent().getMaxx()) + " " +
                    
String.valueOf(mapObj_o.getExtent().getMaxy()));//set the actual extent 
in a hidden input element of the form
       
    }

I've tried also

private void draw(mapObj mapObj_o){
            toggleLayer(mapObj_o);
            imageObj mapImageObj;
            String imageName = getImageName();
            String imagePath = IMAGE_URL + imageName;
            mapObj_o.setSize(WIDTH, HEIGHT);
            mapImageObj = mapObj_o.draw();
            mapImageObj.save(imagePath, mapObj_o);
            setMappa("/map/" + imageName);
            
setCurrent_extent(String.valueOf(mapObj_o.getExtent().getMinx()) + " " +
                    String.valueOf(mapObj_o.getExtent().getMiny()) + " " +
                    String.valueOf(mapObj_o.getExtent().getMaxx()) + " " +
                    String.valueOf(mapObj_o.getExtent().getMaxy()));
       
    }

Umberto Nicoletti ha scritto:
> On Sun, Sep 28, 2008 at 11:45 AM, Ludovico Bianchini <metlud at yahoo.it> wrote:
>   
>> - Windows Vista Home Premium
>> - Postgres 8.1
>> - jvm 1.6.0
>> - jboss 4.0.3SP1, tomcat 5.5
>> - struts2
>> - ms4w 2.3.0 (mapscript.jar, mapscript.dll, all other dlls taken from this
>> pack)
>> - postgresql-8.2-505.jdbc4.jar
>>
>> The query created to extract postgis layer is of the type
>>
>> SELECT asbinary(force_collection(force_2d(posizionegeoref)),'NDR') from
>> rilievi.impianti where posizionegeoref && setSRID('BOX3D(0 0,599
>> 399)'::BOX3D, find_srid('','rilievi.impianti','posizionegeoref') );
>>
>> The BOX3D filter is created using pixel map's limits...(  BOX3D(0 0,599 399)
>>  ) why this?
>>
>> I use setExtent() before draw(), all navigation operations work fine, why is
>> the query build against the pixel
>> dimensions of the resulting image and not against the real dimensions
>> calculated for the rectangle?
>>     
>
> do you call setExtent before querying and convert image units into map units?
>
>   
>> Perhaps I am missing some basic instructions, but I don't know what...
>>
>> Thanks in advance for any suggestions.
>> Ludovico
>> Chiacchiera con i tuoi amici in tempo reale!
>> http://it.yahoo.com/mail_it/foot/*http://it.messenger.yahoo.com
>> _______________________________________________
>> mapserver-users mailing list
>> mapserver-users at lists.osgeo.org
>> http://lists.osgeo.org/mailman/listinfo/mapserver-users
>>
>>     
>
>
>   

Chiacchiera con i tuoi amici in tempo reale! 
 http://it.yahoo.com/mail_it/foot/*http://it.messenger.yahoo.com 



More information about the mapserver-users mailing list