GeoServer

Generate LatLongBoundingBox dynamically

Details

  • Type: Improvement Improvement
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Fixed
  • Affects Version/s: 1.1.0
  • Fix Version/s: 1.3.0
  • Component/s: Configuration
  • Labels:
    None
  • Environment:
    All
  • Number of attachments :
    0

Description

Figuring out the LatLongBoundingBox is one of the more annoying tasks of configuration, as one must either know it or go through a bunch of math to get it. GeoServer should have all this information, as DataStore's can provide their bounds, and geotools can do the transformation into LatLong. Users should not have to worry about this, it should just be taken care of, and removed from the configuration for featureTypes.

Issue Links

Activity

Hide
Chris Holmes added a comment -

How to do this, from geotoo

<groldan> MartinD: can you point me to how transform a bbox into EPSG:4326? or did you already did it Chris?
<groldan> (for geoserver)
<MartinD> What is the source CS?
<MartinD> I mean, do you know the source CS by its EPSG code, or something else?
<groldan> can be any
<groldan> I should know it
<groldan> since I have to have it to configure the featuretype in geoserver
<groldan> I'm asking you cause I think you're doing it in renderer
<MartinD> (just a minute...)
<MartinD> Sorry, I was talking with Andrea about J2D-renderer...
<MartinD> The first step is to get the source CoordinateSystem.
<MartinD> If you know the EPSG code, you can use CoordinateSystemEPSGFactory.
<MartinD> If you know its WKT text instead, you can use CoordinateSystemFactory.createFromWKT(...)
<MartinD> For the target CS (EPSG:4326), you can use the GeographicCoordinateSystem.WGS84 constant.
<MartinD> (if I'm remembering right the WGS84 EPSG code)
<MartinD> Once you have the source and target CS, you can use the following:
<MartinD> CoordinateTransformation tr = coordinateTransformationFactory.createFromCoordinateSystem(sourceCS, targetCS)
<MartinD> You get the object which can be used for any amount of transformations from sourceCS to targetCS.
<groldan> great! lots of thanks
<MartinD> Since all the above step are somewhat costly, it may be wise to save the resulting CoordinateTransformation object for future reuse if you know that sourceCS and targetCS will not change.
<MartinD> Then, for the specific case of transforming a Rectangle2D or an Envelope, you can do it yourself by transforming each corner, or use the following convenience method:
<MartinD> CTSUtilities.transform(MathTransform, Envelope)
<MartinD> or
<MartinD> CTSUtilities.transform(MathTransform, Rectangle2D)
<MartinD> (in org.geotools.resources)
<aaime> Going bed, bye
<MartinD> Note that CTSUtilities is a convenience method for internal use in Geotools; it is not target as a really public class since it is somewhat a hack, not very rigorous.
<-- aaime (~wolf@host149-73.pool80180.interbusiness.it) has left #geotools
<MartinD> (it is not as easy as it may seems to transform a rectangle using a more general transform than an AffineTransform)

Show
Chris Holmes added a comment - How to do this, from geotoo <groldan> MartinD: can you point me to how transform a bbox into EPSG:4326? or did you already did it Chris? <groldan> (for geoserver) <MartinD> What is the source CS? <MartinD> I mean, do you know the source CS by its EPSG code, or something else? <groldan> can be any <groldan> I should know it <groldan> since I have to have it to configure the featuretype in geoserver <groldan> I'm asking you cause I think you're doing it in renderer <MartinD> (just a minute...) <MartinD> Sorry, I was talking with Andrea about J2D-renderer... <MartinD> The first step is to get the source CoordinateSystem. <MartinD> If you know the EPSG code, you can use CoordinateSystemEPSGFactory. <MartinD> If you know its WKT text instead, you can use CoordinateSystemFactory.createFromWKT(...) <MartinD> For the target CS (EPSG:4326), you can use the GeographicCoordinateSystem.WGS84 constant. <MartinD> (if I'm remembering right the WGS84 EPSG code) <MartinD> Once you have the source and target CS, you can use the following: <MartinD> CoordinateTransformation tr = coordinateTransformationFactory.createFromCoordinateSystem(sourceCS, targetCS) <MartinD> You get the object which can be used for any amount of transformations from sourceCS to targetCS. <groldan> great! lots of thanks <MartinD> Since all the above step are somewhat costly, it may be wise to save the resulting CoordinateTransformation object for future reuse if you know that sourceCS and targetCS will not change. <MartinD> Then, for the specific case of transforming a Rectangle2D or an Envelope, you can do it yourself by transforming each corner, or use the following convenience method: <MartinD> CTSUtilities.transform(MathTransform, Envelope) <MartinD> or <MartinD> CTSUtilities.transform(MathTransform, Rectangle2D) <MartinD> (in org.geotools.resources) <aaime> Going bed, bye <MartinD> Note that CTSUtilities is a convenience method for internal use in Geotools; it is not target as a really public class since it is somewhat a hack, not very rigorous. <-- aaime (~wolf@host149-73.pool80180.interbusiness.it) has left #geotools <MartinD> (it is not as easy as it may seems to transform a rectangle using a more general transform than an AffineTransform)
Hide
Chris Holmes added a comment -

How to do this, from geotoo

<groldan> MartinD: can you point me to how transform a bbox into EPSG:4326? or did you already did it Chris?
<groldan> (for geoserver)
<MartinD> What is the source CS?
<MartinD> I mean, do you know the source CS by its EPSG code, or something else?
<groldan> can be any
<groldan> I should know it
<groldan> since I have to have it to configure the featuretype in geoserver
<groldan> I'm asking you cause I think you're doing it in renderer
<MartinD> (just a minute...)
<MartinD> Sorry, I was talking with Andrea about J2D-renderer...
<MartinD> The first step is to get the source CoordinateSystem.
<MartinD> If you know the EPSG code, you can use CoordinateSystemEPSGFactory.
<MartinD> If you know its WKT text instead, you can use CoordinateSystemFactory.createFromWKT(...)
<MartinD> For the target CS (EPSG:4326), you can use the GeographicCoordinateSystem.WGS84 constant.
<MartinD> (if I'm remembering right the WGS84 EPSG code)
<MartinD> Once you have the source and target CS, you can use the following:
<MartinD> CoordinateTransformation tr = coordinateTransformationFactory.createFromCoordinateSystem(sourceCS, targetCS)
<MartinD> You get the object which can be used for any amount of transformations from sourceCS to targetCS.
<groldan> great! lots of thanks
<MartinD> Since all the above step are somewhat costly, it may be wise to save the resulting CoordinateTransformation object for future reuse if you know that sourceCS and targetCS will not change.
<MartinD> Then, for the specific case of transforming a Rectangle2D or an Envelope, you can do it yourself by transforming each corner, or use the following convenience method:
<MartinD> CTSUtilities.transform(MathTransform, Envelope)
<MartinD> or
<MartinD> CTSUtilities.transform(MathTransform, Rectangle2D)
<MartinD> (in org.geotools.resources)
<aaime> Going bed, bye
<MartinD> Note that CTSUtilities is a convenience method for internal use in Geotools; it is not target as a really public class since it is somewhat a hack, not very rigorous.
<-- aaime (~wolf@host149-73.pool80180.interbusiness.it) has left #geotools
<MartinD> (it is not as easy as it may seems to transform a rectangle using a more general transform than an AffineTransform)

Show
Chris Holmes added a comment - How to do this, from geotoo <groldan> MartinD: can you point me to how transform a bbox into EPSG:4326? or did you already did it Chris? <groldan> (for geoserver) <MartinD> What is the source CS? <MartinD> I mean, do you know the source CS by its EPSG code, or something else? <groldan> can be any <groldan> I should know it <groldan> since I have to have it to configure the featuretype in geoserver <groldan> I'm asking you cause I think you're doing it in renderer <MartinD> (just a minute...) <MartinD> Sorry, I was talking with Andrea about J2D-renderer... <MartinD> The first step is to get the source CoordinateSystem. <MartinD> If you know the EPSG code, you can use CoordinateSystemEPSGFactory. <MartinD> If you know its WKT text instead, you can use CoordinateSystemFactory.createFromWKT(...) <MartinD> For the target CS (EPSG:4326), you can use the GeographicCoordinateSystem.WGS84 constant. <MartinD> (if I'm remembering right the WGS84 EPSG code) <MartinD> Once you have the source and target CS, you can use the following: <MartinD> CoordinateTransformation tr = coordinateTransformationFactory.createFromCoordinateSystem(sourceCS, targetCS) <MartinD> You get the object which can be used for any amount of transformations from sourceCS to targetCS. <groldan> great! lots of thanks <MartinD> Since all the above step are somewhat costly, it may be wise to save the resulting CoordinateTransformation object for future reuse if you know that sourceCS and targetCS will not change. <MartinD> Then, for the specific case of transforming a Rectangle2D or an Envelope, you can do it yourself by transforming each corner, or use the following convenience method: <MartinD> CTSUtilities.transform(MathTransform, Envelope) <MartinD> or <MartinD> CTSUtilities.transform(MathTransform, Rectangle2D) <MartinD> (in org.geotools.resources) <aaime> Going bed, bye <MartinD> Note that CTSUtilities is a convenience method for internal use in Geotools; it is not target as a really public class since it is somewhat a hack, not very rigorous. <-- aaime (~wolf@host149-73.pool80180.interbusiness.it) has left #geotools <MartinD> (it is not as easy as it may seems to transform a rectangle using a more general transform than an AffineTransform)
Hide
Chris Holmes added a comment -

Move this 1.2.1 and reassign to me if you don't have time. But it's a nice little thing to ease user config. Might be more of a bitch than it looks though, as crs stuff can be nasty.

Show
Chris Holmes added a comment - Move this 1.2.1 and reassign to me if you don't have time. But it's a nice little thing to ease user config. Might be more of a bitch than it looks though, as crs stuff can be nasty.
Hide
David Zwiers added a comment -

Please complete the code in org.vfny.geoserver.action.data.DataFeatureTypesNewAction.

ftConfig.setSRS(0);
FeatureSource fs = dataStore.getFeatureSource(featureType.getTypeName());
Envelope ev = fs.getBounds();
if(ev == null || ev.isNull()){
try{ ev = fs.getFeatures().getBounds(); }catch(Throwable t){ ev = null; }
}

// TODO translate to lat long, pending
ftConfig.setLatLongBBox(ev);

The code would follow something like:

//Extent ex = featureType.getDefaultGeometry().getCoordinateSystem().etValidArea();
//ftConfig.setLatLongBBox(ex);

http://geoapi.sourceforge.net/javadoc/index.html

Show
David Zwiers added a comment - Please complete the code in org.vfny.geoserver.action.data.DataFeatureTypesNewAction. ftConfig.setSRS(0); FeatureSource fs = dataStore.getFeatureSource(featureType.getTypeName()); Envelope ev = fs.getBounds(); if(ev == null || ev.isNull()){ try{ ev = fs.getFeatures().getBounds(); }catch(Throwable t){ ev = null; } } // TODO translate to lat long, pending ftConfig.setLatLongBBox(ev); The code would follow something like: //Extent ex = featureType.getDefaultGeometry().getCoordinateSystem().etValidArea(); //ftConfig.setLatLongBBox(ex); http://geoapi.sourceforge.net/javadoc/index.html
Hide
Chris Holmes added a comment -

The ui is going to do this first, then we'll figure out how to do it all dynamically.

Show
Chris Holmes added a comment - The ui is going to do this first, then we'll figure out how to do it all dynamically.
Hide
Chris Holmes added a comment -

Linked to GEOS-147, as they are very similar, but have different and good comments.

Show
Chris Holmes added a comment - Linked to GEOS-147, as they are very similar, but have different and good comments.
Hide
dblasby added a comment -

most of this is done. Its not automatic because the user has to correctly specify the projection.

Show
dblasby added a comment - most of this is done. Its not automatic because the user has to correctly specify the projection.
Hide
Chris Holmes added a comment -

Fixed long ago.

Show
Chris Holmes added a comment - Fixed long ago.

People

Vote (1)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved:

Time Tracking

Estimated:
3h
Original Estimate - 3 hours
Remaining:
3h
Remaining Estimate - 3 hours
Logged:
Not Specified
Time Spent - Not Specified