need help for zoom function

9 messages Options
Embed this post
Permalink
dadar

need help for zoom function

Reply Threaded More More options
Print post
Permalink
i want to make my own zoom function likee the one in mapdisplaylab.java
is there any example about the zoom function??
or where can i start to learn more about it??
i have been told that we can make it using  referenced envelope but i'm still confuse and still not understand
anyone who understand it please help me >.<

Darmawan
Miles Jordan

Using ogc:PropertyIsLike on numeric property (postgis) [Sec=Unclassified]

Reply Threaded More More options
Print post
Permalink
Hi,

In an attempt to filter a layer containing contour lines, showing only lines with an elevation divisible by 1000, I tried using:

<ogc:Filter>
    <ogc:PropertyIsLike wildCard='*' singleChar='.' escape='!'>
        <ogc:PropertyName>elevation</ogc:PropertyName>
        <ogc:Literal>*000.0</ogc:Literal>
    </ogc:PropertyIsLike>
</ogc:Filter>

But this approach fails with "org.postgresql.util.PSQLException: ERROR: function upper(numeric) does not exist".

Obviously it is failing because the attribute is numeric and it's trying to do a string conversion on it.

The same Filter actually works with a shapefile as the datasource.

I can write the filter differently, but, I wonder if this is the expected result or not - as the filter encoding spec doesn't mention that the Literal in question must be a string?

Here is the exception:

Caused by: org.postgresql.util.PSQLException: ERROR: function upper(numeric) does not exist
  Hint: No function matches the given name and argument types. You might need to add explicit type casts.
  Position: 174
        at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2062)
        at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1795)
        at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:257)
        at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:479)
        at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:367)
        at org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:271)
        at org.apache.commons.dbcp.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:93)
        at org.geotools.jdbc.JDBCFeatureReader.<init>(JDBCFeatureReader.java:156)
        at org.geotools.jdbc.JDBCFeatureSource.getReaderInternal(JDBCFeatureSource.java:556)

Regards,

Miles Jordan
Applications Developer
Australian Antarctic Division
___________________________________________________________________________

    Australian Antarctic Division - Commonwealth of Australia
IMPORTANT: This transmission is intended for the addressee only. If you are not the
intended recipient, you are notified that use or dissemination of this communication is
strictly prohibited by Commonwealth law. If you have received this transmission in error,
please notify the sender immediately by e-mail or by telephoning +61 3 6232 3209 and
DELETE the message.
        Visit our web site at http://www.antarctica.gov.au/
___________________________________________________________________________

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Geotools-gt2-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
mbedward

Re: need help for zoom function

Reply Threaded More More options
Print post
Permalink
In reply to this post by dadar
Hi Darmawan,

Really all that happens with the zoom in and zoom out cursor tools is
that they work out the new map bounds (as a ReferencedEnvelope) and
then call JMapPane.setDisplayArea.

Perhaps the easiest thing for you to do is look at the source code for
ZoomInTool, ZoomOutTool, and their base class AbstractZoomTool. You
can find them all here...

http://svn.osgeo.org/geotools/tags/2.6.0/modules/unsupported/swing/src/main/java/org/geotools/swing/tool/

When using ZoomInTool you can draw a box on the map pane with the
mouse to define the area to zoom in to. The code that draws the box is
part of the JMapPane class so you don't need to implement that
yourself.

Michael

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Geotools-gt2-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
dadar

Re: need help for zoom function

Reply Threaded More More options
Print post
Permalink
Thank you michael. I'll try to studying the example you give me first then

Darmawan

mbedward wrote:
Hi Darmawan,

Really all that happens with the zoom in and zoom out cursor tools is
that they work out the new map bounds (as a ReferencedEnvelope) and
then call JMapPane.setDisplayArea.

Perhaps the easiest thing for you to do is look at the source code for
ZoomInTool, ZoomOutTool, and their base class AbstractZoomTool. You
can find them all here...

http://svn.osgeo.org/geotools/tags/2.6.0/modules/unsupported/swing/src/main/java/org/geotools/swing/tool/

When using ZoomInTool you can draw a box on the map pane with the
mouse to define the area to zoom in to. The code that draws the box is
part of the JMapPane class so you don't need to implement that
yourself.

Michael

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Geotools-gt2-users mailing list
Geotools-gt2-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
Jody Garnett-2

Re: Using ogc:PropertyIsLike on numeric property (postgis) [Sec=Unclassified]

Reply Threaded More More options
Print post
Permalink
In reply to this post by Miles Jordan
Hi Miles :-)

We should fix the like implementation to turn the numeric into a
string and *then* perform a pattern match.  In general the "ogc
filter" language we are using here for query does notknow anything
about type of data - and as a result we morph or convert between types
as required in our java code when implementing.

Can you report a bug; hopefully with a test case.

Jody

On Fri, Oct 30, 2009 at 5:13 PM, Miles Jordan <[hidden email]> wrote:

> Hi,
>
> In an attempt to filter a layer containing contour lines, showing only lines with an elevation divisible by 1000, I tried using:
>
> <ogc:Filter>
>    <ogc:PropertyIsLike wildCard='*' singleChar='.' escape='!'>
>        <ogc:PropertyName>elevation</ogc:PropertyName>
>        <ogc:Literal>*000.0</ogc:Literal>
>    </ogc:PropertyIsLike>
> </ogc:Filter>
>
> But this approach fails with "org.postgresql.util.PSQLException: ERROR: function upper(numeric) does not exist".
>
> Obviously it is failing because the attribute is numeric and it's trying to do a string conversion on it.
>
> The same Filter actually works with a shapefile as the datasource.
>
> I can write the filter differently, but, I wonder if this is the expected result or not - as the filter encoding spec doesn't mention that the Literal in question must be a string?
>
> Here is the exception:
>
> Caused by: org.postgresql.util.PSQLException: ERROR: function upper(numeric) does not exist
>  Hint: No function matches the given name and argument types. You might need to add explicit type casts.
>  Position: 174
>        at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2062)
>        at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1795)
>        at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:257)
>        at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:479)
>        at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:367)
>        at org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:271)
>        at org.apache.commons.dbcp.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:93)
>        at org.geotools.jdbc.JDBCFeatureReader.<init>(JDBCFeatureReader.java:156)
>        at org.geotools.jdbc.JDBCFeatureSource.getReaderInternal(JDBCFeatureSource.java:556)
>
> Regards,
>
> Miles Jordan
> Applications Developer
> Australian Antarctic Division
> ___________________________________________________________________________
>
>    Australian Antarctic Division - Commonwealth of Australia
> IMPORTANT: This transmission is intended for the addressee only. If you are not the
> intended recipient, you are notified that use or dissemination of this communication is
> strictly prohibited by Commonwealth law. If you have received this transmission in error,
> please notify the sender immediately by e-mail or by telephoning +61 3 6232 3209 and
> DELETE the message.
>        Visit our web site at http://www.antarctica.gov.au/
> ___________________________________________________________________________
>
> ------------------------------------------------------------------------------
> Come build with us! The BlackBerry(R) Developer Conference in SF, CA
> is the only developer event you need to attend this year. Jumpstart your
> developing skills, take BlackBerry mobile applications to market and stay
> ahead of the curve. Join us from November 9 - 12, 2009. Register now!
> http://p.sf.net/sfu/devconference
> _______________________________________________
> Geotools-gt2-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
>

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Geotools-gt2-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
dadar

Re: need help for zoom function

Reply Threaded More More options
Print post
Permalink
In reply to this post by mbedward
Michael, I have some problem about my function. when I try to getScaleX() i have an error java.lang.NullPointerException
I try to make zoom in function right after i set my style.
am I wrong about that? or is there any other way to getScaleX??
I change the function where I found in ZoomInTool.java so I don't need to click the mouse to zoom in

public void finalizestyle(){
         Rule otherRule = createRule(LINE_COLOUR, FILL_COLOUR,false);
         otherRule.setElseFilter(true);
         fixfts.rules().add(otherRule);
         stylefinal.featureTypeStyles().add(fixfts);
         mapFrame.getMapContext().getLayer(0).setStyle(stylefinal);
         mapFrame.getMapPane().repaint();

        Rectangle paneArea = mapFrame.getMapPane().getVisibleRect();


        double scale = mapFrame.getMapPane().getWorldToScreenTransform().getScaleX();
        double newScale = scale * 5;

        DirectPosition2D corner = new DirectPosition2D(
                posisix[0] - 0.5d * paneArea.getWidth() / newScale,
                posisiy[0] + 0.5d * paneArea.getHeight() / newScale);

        DirectPosition2D mapPos = null;
        mapPos.x=posisix[0];
        mapPos.y=posisiy[0];
        Envelope2D newMapArea = new Envelope2D();
        newMapArea.setFrameFromCenter(mapPos, corner);
        mapFrame.getMapPane().setDisplayArea(newMapArea);

         
     }

Darmawan
mbedward wrote:
Hi Darmawan,

Really all that happens with the zoom in and zoom out cursor tools is
that they work out the new map bounds (as a ReferencedEnvelope) and
then call JMapPane.setDisplayArea.

Perhaps the easiest thing for you to do is look at the source code for
ZoomInTool, ZoomOutTool, and their base class AbstractZoomTool. You
can find them all here...

http://svn.osgeo.org/geotools/tags/2.6.0/modules/unsupported/swing/src/main/java/org/geotools/swing/tool/

When using ZoomInTool you can draw a box on the map pane with the
mouse to define the area to zoom in to. The code that draws the box is
part of the JMapPane class so you don't need to implement that
yourself.

Michael

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Geotools-gt2-users mailing list
Geotools-gt2-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
dadar

Re: need help for zoom function

Reply Threaded More More options
Print post
Permalink
In reply to this post by mbedward
Michael, I have some problem about my function. when I try to getScaleX() i have an error java.lang.NullPointerException
I try to make zoom in function right after i set my style.
am I wrong about that? or is there any other way to getScaleX??
I change the function where I found in ZoomInTool.java so I don't need to click the mouse to zoom in

public void finalizestyle(){
         Rule otherRule = createRule(LINE_COLOUR, FILL_COLOUR,false);
         otherRule.setElseFilter(true);
         fixfts.rules().add(otherRule);
         stylefinal.featureTypeStyles().add(fixfts);
         mapFrame.getMapContext().getLayer(0).setStyle(stylefinal);
         mapFrame.getMapPane().repaint();

        Rectangle paneArea = mapFrame.getMapPane().getVisibleRect();


        double scale = mapFrame.getMapPane().getWorldToScreenTransform().getScaleX();
        double newScale = scale * 5;

        DirectPosition2D corner = new DirectPosition2D(
                posisix[0] - 0.5d * paneArea.getWidth() / newScale,
                posisiy[0] + 0.5d * paneArea.getHeight() / newScale);

        DirectPosition2D mapPos = null;
        mapPos.x=posisix[0];
        mapPos.y=posisiy[0];
        Envelope2D newMapArea = new Envelope2D();
        newMapArea.setFrameFromCenter(mapPos, corner);
        mapFrame.getMapPane().setDisplayArea(newMapArea);

         
     }

Darmawan
mbedward wrote:
Hi Darmawan,

Really all that happens with the zoom in and zoom out cursor tools is
that they work out the new map bounds (as a ReferencedEnvelope) and
then call JMapPane.setDisplayArea.

Perhaps the easiest thing for you to do is look at the source code for
ZoomInTool, ZoomOutTool, and their base class AbstractZoomTool. You
can find them all here...

http://svn.osgeo.org/geotools/tags/2.6.0/modules/unsupported/swing/src/main/java/org/geotools/swing/tool/

When using ZoomInTool you can draw a box on the map pane with the
mouse to define the area to zoom in to. The code that draws the box is
part of the JMapPane class so you don't need to implement that
yourself.

Michael

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Geotools-gt2-users mailing list
Geotools-gt2-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
mbedward

Re: need help for zoom function

Reply Threaded More More options
Print post
Permalink
In reply to this post by dadar
Hi Darmawan,

You're on the right track.

I am guessing that you are calling the getScaleX() method before the
map pane has been displayed for the first time. The world to screen
transform (an AffineTransform object) is not created until the pane is
displayed.

(Actually, your question makes me think it might be better to change
JMapPane so that the transform is created as soon as the map pane has
its size set and is connected to a map context with layers).

Michael

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Geotools-gt2-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
Miles Jordan

Re: Using ogc:PropertyIsLike on numeric property (postgis) [Sec=Unclassified]

Reply Threaded More More options
Print post
Permalink
In reply to this post by Jody Garnett-2
Jody Garnett wrote:
> We should fix the like implementation to turn the numeric into a
> string and *then* perform a pattern match.  In general the "ogc
> filter" language we are using here for query does notknow anything
> about type of data - and as a result we morph or convert between types
> as required in our java code when implementing.
>
> Can you report a bug; hopefully with a test case.


Sure thing. Thanks for clearing it up. Is that a postgis datastore issue or filter?

Miles
___________________________________________________________________________

    Australian Antarctic Division - Commonwealth of Australia
IMPORTANT: This transmission is intended for the addressee only. If you are not the
intended recipient, you are notified that use or dissemination of this communication is
strictly prohibited by Commonwealth law. If you have received this transmission in error,
please notify the sender immediately by e-mail or by telephoning +61 3 6232 3209 and
DELETE the message.
        Visit our web site at http://www.antarctica.gov.au/
___________________________________________________________________________

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Geotools-gt2-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users