Ahmed Abdeen Hamed | 1 Apr 2010 02:48
Picon

Re: Shape file entries - String to numerical?

Hey Linda,
Use the code snippet below to parse the "String" number objects to get their "int" numeric values. First, you must make sure that you are parsing "String" numerics not just text to int primitives, otherwise, it will do you no good to parse them. Second, you must try/catch for a NumberFormatException in case you are reading a String that is not number. If you know that your String numeric might exceed the range of an int, you might want to parse for "long" primitives instead:

Now here is what you should do for parsing int primitives:
        try{       
        // this will be valid and won't throw up on you   
        int myInt0 = Integer.parseInt("1221");       
       
        // this is no good and will throw up on you :-)
        int myInt1 = Integer.parseInt("23sdf");
        }catch(NumberFormatException ex){
            System.out.println(ex.getMessage());
        }

For parsing String numeric that fit "long" primitives, you should use:
long myLong = Long.parseLong("87698798798723423");

Hope this solves your issue!
Best wishes,
Ahmed


On Wed, Mar 31, 2010 at 6:04 PM, Adnila <Adnila-S0/GAf8tV78@public.gmane.org> wrote:

hey guys,
I have another question. I do not know if it is really stuff for geotools.

Because the attributeName parameter from VectorToRaster.process() is
numerical, I have to change some elements in my shape file.

These are the facts:
I have a huge amount of colums with String entries. But in reality the
values are not Strings, but numeric entries. What now?
I have to evaluate all entries, if there is a number in it or not. And if
so, how to check on the elements? And then change it to some numeric
entries?!
Has anybody any idea how to do this with less effort?

<at> michael: did you check already my code from
http://n2.nabble.com/GridCoverage-Error-Points-of-LinearRing-do-not-form-a-closed-linestring-raster-attribute-matrix-tt4783764.html#a4783764.
I send it to you via email.

Thanks for your help
Linda

--
View this message in context: http://n2.nabble.com/Shape-file-entries-String-to-numerical-tp4833774p4833774.html
Sent from the geotools-gt2-users mailing list archive at Nabble.com.

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Geotools-gt2-users mailing list
Geotools-gt2-users-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Geotools-gt2-users mailing list
Geotools-gt2-users@...
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
David Abdurachmanov | 1 Apr 2010 15:58
Picon
Favicon

MapPane turning off auto reset on resize

Hello,

Is it possible to turn off the reseting to full extent on resize? Doesn't look that there would be any kind of option for that. Tried adding MapPaneListener and saving display area and later on resized event changing it back, but wasn't successfully. Any hints how you accomplish this? I want MapPane to stay on the same area after resizing.

Thanks,
David

Your E-mail and More On-the-Go. Get Windows Live Hotmail Free. Sign up now.
------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Geotools-gt2-users mailing list
Geotools-gt2-users@...
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
Richard Marshall | 1 Apr 2010 17:19
Picon
Favicon

Geometry offset function


Hi
I am attempting to create a simple filter function that would allow me to
place a graphic, using a PointSymbolizer, at an offset to the point
geometry.  The function would expect two parameters, an x-offset and a
y-offset (I know this is very simplistic, I will need to take into account
the current map scale later).  I would use the function something like this:

  pointSymbolizer.setGeometry(ff.function("GeometryOffset",
ff.literal(0.0001), ff.literal(0.0001)));

I created a function by extending FunctionExpressionImpl and registered it,
the evaluate method is shown below:

   <at> Override
  public Object evaluate(Object feature)
  {
    if (!(feature instanceof SimpleFeature))
    {
      return null;
    }
    Expression xOffset = (Expression)getParameters().get(0);
    Expression yOffset = (Expression)getParameters().get(1);

    double first = ((Number)xOffset.evaluate(feature)).doubleValue();
    double second = ((Number)yOffset.evaluate(feature)).doubleValue();

    Object originalPoint = ((SimpleFeature)feature).getDefaultGeometry();
    if (!(originalPoint instanceof Geometry))
    {
      return null;
    }

    Coordinate originalCoordinate =
((Geometry)originalPoint).getCoordinate();
    Coordinate newCoordinate = new Coordinate(originalCoordinate.x + first,
originalCoordinate.y + second);

    GeometryFactory geometryFactory =
JTSFactoryFinder.getGeometryFactory(null);
    Point newPoint = geometryFactory.createPoint(newCoordinate);

    return newPoint;
  }

This is not working, the graphic is not displayed at all.  Any hints would
be very appreciated.  I noticed in the javadocs for the
setGeometry/getGeometry methods that 'it is advised that the Expression
implements the SpatialTransformationFunction interface', I have not been
able to locate this interface.

Thanks,
Richard

--

-- 
View this message in context: http://n2.nabble.com/Geometry-offset-function-tp4837712p4837712.html
Sent from the geotools-gt2-users mailing list archive at Nabble.com.

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
Martin | 1 Apr 2010 17:56
Picon

The Result of LengthIndexedLine is WRONG

Hi all,

 

i have a „big“ problem consider following example:

 

WKTReader reader = new WKTReader();

 

            LineString line1 = (LineString) reader

                        .read("LINESTRING (16785.531699445004 1002.8279659806619, 12455.57517093993 1000.3494562333781, 12333.457215546126 1024.2034008729838)");

            LengthIndexedLine temp = new LengthIndexedLine(line1);

 

            Coordinate c = new Coordinate(16785.531699445004,1002.8279659806619);

            double startindex = temp.indexOf(c);

            System.out.println(startindex);

           

            // Get point that lies 200 meters from startindex

            double endindex = startindex+200;

           

            LineString line2 = (LineString) temp.extractLine(startindex, endindex);

            System.out.println("Line1"+line1);

            System.out.println("Line2"+line2);

            System.out.println("Intersected line"+line1.intersection(line2));

 

I have one line (here line1) and need to calculate the line from startpoint of line1 to 200 “meters” further!

BUT the result line (here line2) should have a “intersection line” with length 200 meters => but it hasn`t!

 

Can anyone help me out I really need a “robust” solution!

 

Best regards,

Martin

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Geotools-gt2-users mailing list
Geotools-gt2-users@...
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
Michael geotools | 2 Apr 2010 11:05
Favicon

Re: loading shape file after tiff


mbedward wrote:
> 
> PS. this might help too...
> http://jira.codehaus.org/browse/GEOT-2995
> 

No, unfortunately ( 
I tried to use  System.setProperty("org.geotools.referencing.forceXY",
"true")
and Hints.putSystemDefault(Hints.FORCE_LONGITUDE_FIRST_AXIS_ORDER,
Boolean.TRUE) in different places of my application (before and after load
shp, tiff files, before and after creating MapContext etc), but it did not
help.
--

-- 
View this message in context: http://n2.nabble.com/loading-shape-file-after-tiff-tp4792761p4841843.html
Sent from the geotools-gt2-users mailing list archive at Nabble.com.

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
Michael geotools | 2 Apr 2010 11:31
Favicon

Re: loading shape file after tiff


Hi!
I often switched to other tasks (specifics of my job), so sometimes cannot
answer immediately, sorry...

mbedward wrote:
> 
> My first thought is that this sounds a bit similar to a problem with
> WMSLayers that Andrea found the solution to last week. Is it possible
> that there is a difference in axis definition between the CRS of your
> shapefile and the CRS of your image ?
> No, there are no difference in axis definition. 

mbedward wrote:
> 
> If you become convinced that it's a bug in the gt-swing module please
> create a Jira issue and assign it to me so that I don't forget about
> it.
I think its  a bug, because after mapPane.reset() all displayed fine. I call
reset() method after load any file and it solve problem for now.
Later I will try to create Jira issue for you, if you do not mind...

Thanks,
Michael
--

-- 
View this message in context: http://n2.nabble.com/loading-shape-file-after-tiff-tp4792761p4841933.html
Sent from the geotools-gt2-users mailing list archive at Nabble.com.

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
Michael geotools | 2 Apr 2010 11:45
Favicon

Re: PanAction


Hello Michael,
Maybe I should create Jira issue for this situation, whats your opinion?

Thanks!
--

-- 
View this message in context: http://n2.nabble.com/PanAction-tp4776894p4841964.html
Sent from the geotools-gt2-users mailing list archive at Nabble.com.

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
Michael geotools | 2 Apr 2010 11:50
Favicon

Re: loading shape file after tiff


Hi! 
I often switched to other tasks (specifics of my job), so sometimes cannot
answer immediately, sorry... 

mbedward wrote:
> 
> My first thought is that this sounds a bit similar to a problem with 
> WMSLayers that Andrea found the solution to last week. Is it possible 
> that there is a difference in axis definition between the CRS of your 
> shapefile and the CRS of your image ? 
> 

No, there are no difference in axis definition. 

mbedward wrote:
> 
> If you become convinced that it's a bug in the gt-swing module please 
> create a Jira issue and assign it to me so that I don't forget about 
> it.
> 

I think its  a bug, because after mapPane.reset() all displayed fine. I call
reset() method after load any file and it solve problem for now. 
Later I will try to create Jira issue for you, if you do not mind... 

Thanks, 
Michael

--

-- 
View this message in context: http://n2.nabble.com/loading-shape-file-after-tiff-tp4792761p4841973.html
Sent from the geotools-gt2-users mailing list archive at Nabble.com.

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
Martin | 2 Apr 2010 13:07
Picon

Results of intersections method are false!!

Hi all,

 

me again ! I thing the result of the intersection method for input of two lines are wrong!

Following example:

given a LineString (0 0 , 5 3) and the with formula I compute the y coordinate of a point that lies! On the line!

  

   GeometryFactory fact = new GeometryFactory();

      WKTReader reader = new WKTReader(fact);

 

      LineString line1= (LineString) reader

                  .read("LINESTRING (0 0, 5 3)");

 

     double y1=0;

     double x1=0;

     double x2=5;

     double y2=3;

     double x=1.2;

     double y = y1+(x-x1)*(y2-y1)/(x2-x1);

     System.out.println(y);

  

     LineString line2= (LineString) reader

            .read("LINESTRING (0 0, 1.2 0.72)");

     System.out.println(line1.intersection(line2));

    

for example x=1.2 => result y = 0.72

 

so I build another line use the intersection method and surprise only a point intersection!

This is wrong!

 

So anyone has a hint for me how to get valid! Results?

 

 

Cheers,

Martin

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Geotools-gt2-users mailing list
Geotools-gt2-users@...
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
Adnila | 2 Apr 2010 20:58
Picon

Values of shape file, HDF


Hi guys, 
I am totally confused. I have no clue how to deal with the following
problem. 

As I already said some time ago, I would like to change values in the shape
file. But I have no idea how to get these values, for example an attribute
area with the values which belong to it. Maybe it is just too simple that I
cannot see the solution. 

Another problem I cannot deal with, is how to write an GridCoverage2D. There
are no specifications how to deal with it, just to create an HDF file from
it. It does not matter which concrete format. But I am not able to deal with
it. I have an GridCoverage2D (received from VectorToRasterProcess from shape
file) and want to have a HDF file. 

Can somebody please help me?
Linda

--

-- 
View this message in context: http://n2.nabble.com/Values-of-shape-file-HDF-tp4843991p4843991.html
Sent from the geotools-gt2-users mailing list archive at Nabble.com.

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev

Gmane