[Geoserver-users] Updating a layer's bounding box after WFS-T insert

I'm creating a data store from an OpenLayers DrawFeature control, using WFS-T to save the geometry into GeoServer. This works great, except the data store's bounding box doesn't get set in GeoServer. However, if you create a data store from a shapefile, the bounding box gets automatically set. I know you can go into the GeoServer admin page and tell it to calculate the bounding box, but I need a way to do it programmatically. I appreciate any help.

Thanks,
Ryan

I may be wrong, but my impression (biased by the meaning of the WMS
layer bounds in the spec) is that the bounds you declare for the layer
are purely informative and intend to declare what the area of validity
for the Layer/FeatureType is. In any case it has to be accurate, so a
good practice would be to set the layer bounds to the intended area of
interest for the layer to start with.
So even if a layer has no features, but represents a state wide set of
something, it'd be good to set the metadata layer bounds to the whole
state bounds, for example.
The GeoServer "calculate bounds" button is merely an utility to simplify
the common case. But IMHO you should set the bounds to the widest
possible area the layer is meant to.

2c/
Gabriel

On Mon, 2011-05-23 at 10:31 -0500, Ryan Zoerb wrote:

I'm creating a data store from an OpenLayers DrawFeature control, using
WFS-T to save the geometry into GeoServer. This works great, except
the data store's bounding box doesn't get set in GeoServer. However,
if you create a data store from a shapefile, the bounding box gets
automatically set. I know you can go into the GeoServer admin page and
tell it to calculate the bounding box, but I need a way to do it
programmatically. I appreciate any help.

Thanks,
Ryan
------------------------------------------------------------------------------
What Every C/C++ and Fortran developer Should Know!
Read this article and learn how Intel has extended the reach of its
next-generation tools to help Windows* and Linux* C/C++ and Fortran
developers boost performance applications - including clusters.
http://p.sf.net/sfu/intel-dev2devmay
_______________________________________________
Geoserver-users mailing list
Geoserver-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users

--
Gabriel Roldan
groldan@anonymised.com
Expert service straight from the developers

On Mon, May 23, 2011 at 5:50 PM, Gabriel Roldán <groldan@anonymised.com71…> wrote:

I may be wrong, but my impression (biased by the meaning of the WMS
layer bounds in the spec) is that the bounds you declare for the layer
are purely informative and intend to declare what the area of validity
for the Layer/FeatureType is. In any case it has to be accurate, so a
good practice would be to set the layer bounds to the intended area of
interest for the layer to start with.
So even if a layer has no features, but represents a state wide set of
something, it’d be good to set the metadata layer bounds to the whole
state bounds, for example.
The GeoServer “calculate bounds” button is merely an utility to simplify
the common case. But IMHO you should set the bounds to the widest
possible area the layer is meant to.

I agree with Gabriel, bounds are just an indication.

That said, if you really want to do it anyways, it’s possible to roll a transaction
listener that will try to update the bounds and save them on disk to make
the change persistent.
I would suggest to do it incrementally, that is, just expand the bounds if
you see the inserted/updated feature bounds are outside of the current
layer bounds, for speed reasons.
If you want the bounds to also contract when you do a delete you’ll
have to kick a full computation against the layer contents, depending
on how large your data set it, that might be expensive if not intolerable
(computing bounds on Oracle with tens of millions of rows might
take minutes for example)

Cheers
Andrea

Ing. Andrea Aime
GeoSolutions S.A.S.
Tech lead

Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy

phone: +39 0584 962313
fax: +39 0584 962313

http://www.geo-solutions.it
http://geo-solutions.blogspot.com/
http://www.youtube.com/user/GeoSolutionsIT
http://www.linkedin.com/in/andreaaime
http://twitter.com/geowolf


Thanks for the responses Gabriel and Andrea. I need to get the bounding box of the actual feature (for zooming to the feature in OpenLayers), so I’ll give the transaction listener a try.

-Ryan

On May 23, 2011, at 11:11 AM, Andrea Aime wrote:

On Mon, May 23, 2011 at 5:50 PM, Gabriel Roldán <groldan@anonymised.com> wrote:

I may be wrong, but my impression (biased by the meaning of the WMS
layer bounds in the spec) is that the bounds you declare for the layer
are purely informative and intend to declare what the area of validity
for the Layer/FeatureType is. In any case it has to be accurate, so a
good practice would be to set the layer bounds to the intended area of
interest for the layer to start with.
So even if a layer has no features, but represents a state wide set of
something, it’d be good to set the metadata layer bounds to the whole
state bounds, for example.
The GeoServer “calculate bounds” button is merely an utility to simplify
the common case. But IMHO you should set the bounds to the widest
possible area the layer is meant to.

I agree with Gabriel, bounds are just an indication.

That said, if you really want to do it anyways, it’s possible to roll a transaction
listener that will try to update the bounds and save them on disk to make
the change persistent.
I would suggest to do it incrementally, that is, just expand the bounds if
you see the inserted/updated feature bounds are outside of the current
layer bounds, for speed reasons.
If you want the bounds to also contract when you do a delete you’ll
have to kick a full computation against the layer contents, depending
on how large your data set it, that might be expensive if not intolerable
(computing bounds on Oracle with tens of millions of rows might
take minutes for example)

Cheers
Andrea

Ing. Andrea Aime
GeoSolutions S.A.S.
Tech lead

Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy

phone: +39 0584 962313
fax: +39 0584 962313

http://www.geo-solutions.it
http://geo-solutions.blogspot.com/
http://www.youtube.com/user/GeoSolutionsIT
http://www.linkedin.com/in/andreaaime
http://twitter.com/geowolf


On 23 May 2011 16:59, Ryan Zoerb <razoerb@anonymised.com> wrote:

Thanks for the responses Gabriel and Andrea. I need to get the bounding box
of the actual feature (for zooming to the feature in OpenLayers), so I'll
give the transaction listener a try.

Don't you already know the bounding box of the feature - after all you
generated it.

Ian
--
Ian Turton

Yes, but the problem is I need it to be stored in GeoServer. The polygon can be used both immediately after being drawn (when I have the geometry locally and can figure out its bbox), as well as in future sessions (when I don't).

-Ryan

On May 23, 2011, at 7:09 PM, Ian Turton wrote:

On 23 May 2011 16:59, Ryan Zoerb <razoerb@anonymised.com> wrote:

Thanks for the responses Gabriel and Andrea. I need to get the bounding box
of the actual feature (for zooming to the feature in OpenLayers), so I'll
give the transaction listener a try.

Don't you already know the bounding box of the feature - after all you
generated it.

Ian
--
Ian Turton

I just got around to checking out transaction listeners, and have a couple questions. First, how does one register a listener with the Spring context? Also, how does one update a layer’s bounding box from within a listener? I found this page: http://geoserver.org/display/GEOS/GSIP+14±+WFS+Transaction+handling+framework and have been looking through the wfs code, but I haven’t been able to find any more documentation or examples.

Thanks,
Ryan

On May 23, 2011, at 3:59 PM, Ryan Zoerb wrote:

Thanks for the responses Gabriel and Andrea. I need to get the bounding box of the actual feature (for zooming to the feature in OpenLayers), so I’ll give the transaction listener a try.

-Ryan

On May 23, 2011, at 11:11 AM, Andrea Aime wrote:

On Mon, May 23, 2011 at 5:50 PM, Gabriel Roldán <groldan@anonymised.com> wrote:

I may be wrong, but my impression (biased by the meaning of the WMS
layer bounds in the spec) is that the bounds you declare for the layer
are purely informative and intend to declare what the area of validity
for the Layer/FeatureType is. In any case it has to be accurate, so a
good practice would be to set the layer bounds to the intended area of
interest for the layer to start with.
So even if a layer has no features, but represents a state wide set of
something, it’d be good to set the metadata layer bounds to the whole
state bounds, for example.
The GeoServer “calculate bounds” button is merely an utility to simplify
the common case. But IMHO you should set the bounds to the widest
possible area the layer is meant to.

I agree with Gabriel, bounds are just an indication.

That said, if you really want to do it anyways, it’s possible to roll a transaction
listener that will try to update the bounds and save them on disk to make
the change persistent.
I would suggest to do it incrementally, that is, just expand the bounds if
you see the inserted/updated feature bounds are outside of the current
layer bounds, for speed reasons.
If you want the bounds to also contract when you do a delete you’ll
have to kick a full computation against the layer contents, depending
on how large your data set it, that might be expensive if not intolerable
(computing bounds on Oracle with tens of millions of rows might
take minutes for example)

Cheers
Andrea

Ing. Andrea Aime
GeoSolutions S.A.S.
Tech lead

Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy

phone: +39 0584 962313
fax: +39 0584 962313

http://www.geo-solutions.it
http://geo-solutions.blogspot.com/
http://www.youtube.com/user/GeoSolutionsIT
http://www.linkedin.com/in/andreaaime
http://twitter.com/geowolf


I hooked up a transaction listener by adding a bean to the wfs module’s applicationContext.xml. Is there any way to hook it up in a less invasive manner? Right now I have to compile the wfs module and use it to replace the stock wfs jar in GeoServer’s WEB-INF/lib. I’d rather not replace the whole jar just to add the listener.

Also, I found what looks to be how one would update a layer’s bounding box, but I can’t get it to work. First, I get the layer’s LayerInfo from the catalog by qualified name. From the LayerInfo, I get the associated ResourceInfo, which has setLatLonBoundingBox and setNativeBoundingBox methods. I pass those the ReferencedEnvelope returned by transactionEvent.getAffectedFeatures().getBounds(). I verified that the returned bounds are correct, but the set*BoundingBox methods don’t seem to do anything. After the transaction is done, the layer’s bounds still show up as 0, 0, 0, 0 in both the GeoServer Web UI and WMS GetCaps.

Thanks again for any help,
Ryan

On Jun 10, 2011, at 12:47 PM, Ryan Zoerb wrote:

I just got around to checking out transaction listeners, and have a couple questions. First, how does one register a listener with the Spring context? Also, how does one update a layer’s bounding box from within a listener? I found this page: http://geoserver.org/display/GEOS/GSIP+14±+WFS+Transaction+handling+framework and have been looking through the wfs code, but I haven’t been able to find any more documentation or examples.

Thanks,
Ryan

On May 23, 2011, at 3:59 PM, Ryan Zoerb wrote:

Thanks for the responses Gabriel and Andrea. I need to get the bounding box of the actual feature (for zooming to the feature in OpenLayers), so I’ll give the transaction listener a try.

-Ryan

On May 23, 2011, at 11:11 AM, Andrea Aime wrote:

On Mon, May 23, 2011 at 5:50 PM, Gabriel Roldán <groldan@anonymised.com> wrote:

I may be wrong, but my impression (biased by the meaning of the WMS
layer bounds in the spec) is that the bounds you declare for the layer
are purely informative and intend to declare what the area of validity
for the Layer/FeatureType is. In any case it has to be accurate, so a
good practice would be to set the layer bounds to the intended area of
interest for the layer to start with.
So even if a layer has no features, but represents a state wide set of
something, it’d be good to set the metadata layer bounds to the whole
state bounds, for example.
The GeoServer “calculate bounds” button is merely an utility to simplify
the common case. But IMHO you should set the bounds to the widest
possible area the layer is meant to.

I agree with Gabriel, bounds are just an indication.

That said, if you really want to do it anyways, it’s possible to roll a transaction
listener that will try to update the bounds and save them on disk to make
the change persistent.
I would suggest to do it incrementally, that is, just expand the bounds if
you see the inserted/updated feature bounds are outside of the current
layer bounds, for speed reasons.
If you want the bounds to also contract when you do a delete you’ll
have to kick a full computation against the layer contents, depending
on how large your data set it, that might be expensive if not intolerable
(computing bounds on Oracle with tens of millions of rows might
take minutes for example)

Cheers
Andrea

Ing. Andrea Aime
GeoSolutions S.A.S.
Tech lead

Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy

phone: +39 0584 962313
fax: +39 0584 962313

http://www.geo-solutions.it
http://geo-solutions.blogspot.com/
http://www.youtube.com/user/GeoSolutionsIT
http://www.linkedin.com/in/andreaaime
http://twitter.com/geowolf



EditLive Enterprise is the world’s most technically advanced content
authoring tool. Experience the power of Track Changes, Inline Image
Editing and ensure content is compliant with Accessibility Checking.
http://p.sf.net/sfu/ephox-dev2dev_______________________________________________
Geoserver-users mailing list
Geoserver-users@anonymised.comceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users

You can add the listener to any applicationContext.xml, not just the one in the WFS jar. So probably the simplest way is to create a small Maven project with its own applicationContext.xml and just replace that when you want to update your listener code.

Are you calling org.geoserver.catalog.Catalog:save() on your FeatureType once the bounding box is updated? GeoServer’s catalog system has a basic transaction system and changes won’t be applied immediately upon setting properties of configuration objects.


David Winslow
OpenGeo - http://opengeo.org/

On Mon, Jun 13, 2011 at 5:00 PM, Ryan Zoerb <razoerb@anonymised.com> wrote:

I hooked up a transaction listener by adding a bean to the wfs module’s applicationContext.xml. Is there any way to hook it up in a less invasive manner? Right now I have to compile the wfs module and use it to replace the stock wfs jar in GeoServer’s WEB-INF/lib. I’d rather not replace the whole jar just to add the listener.

Also, I found what looks to be how one would update a layer’s bounding box, but I can’t get it to work. First, I get the layer’s LayerInfo from the catalog by qualified name. From the LayerInfo, I get the associated ResourceInfo, which has setLatLonBoundingBox and setNativeBoundingBox methods. I pass those the ReferencedEnvelope returned by transactionEvent.getAffectedFeatures().getBounds(). I verified that the returned bounds are correct, but the set*BoundingBox methods don’t seem to do anything. After the transaction is done, the layer’s bounds still show up as 0, 0, 0, 0 in both the GeoServer Web UI and WMS GetCaps.

Thanks again for any help,
Ryan

On Jun 10, 2011, at 12:47 PM, Ryan Zoerb wrote:

I just got around to checking out transaction listeners, and have a couple questions. First, how does one register a listener with the Spring context? Also, how does one update a layer’s bounding box from within a listener? I found this page: http://geoserver.org/display/GEOS/GSIP+14±+WFS+Transaction+handling+framework and have been looking through the wfs code, but I haven’t been able to find any more documentation or examples.

Thanks,
Ryan

On May 23, 2011, at 3:59 PM, Ryan Zoerb wrote:

Thanks for the responses Gabriel and Andrea. I need to get the bounding box of the actual feature (for zooming to the feature in OpenLayers), so I’ll give the transaction listener a try.

-Ryan

On May 23, 2011, at 11:11 AM, Andrea Aime wrote:

On Mon, May 23, 2011 at 5:50 PM, Gabriel Roldán <groldan@anonymised.com…> wrote:

I may be wrong, but my impression (biased by the meaning of the WMS
layer bounds in the spec) is that the bounds you declare for the layer
are purely informative and intend to declare what the area of validity
for the Layer/FeatureType is. In any case it has to be accurate, so a
good practice would be to set the layer bounds to the intended area of
interest for the layer to start with.
So even if a layer has no features, but represents a state wide set of
something, it’d be good to set the metadata layer bounds to the whole
state bounds, for example.
The GeoServer “calculate bounds” button is merely an utility to simplify
the common case. But IMHO you should set the bounds to the widest
possible area the layer is meant to.

I agree with Gabriel, bounds are just an indication.

That said, if you really want to do it anyways, it’s possible to roll a transaction
listener that will try to update the bounds and save them on disk to make
the change persistent.
I would suggest to do it incrementally, that is, just expand the bounds if
you see the inserted/updated feature bounds are outside of the current
layer bounds, for speed reasons.
If you want the bounds to also contract when you do a delete you’ll
have to kick a full computation against the layer contents, depending
on how large your data set it, that might be expensive if not intolerable
(computing bounds on Oracle with tens of millions of rows might
take minutes for example)

Cheers
Andrea

Ing. Andrea Aime
GeoSolutions S.A.S.
Tech lead

Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy

phone: +39 0584 962313
fax: +39 0584 962313

http://www.geo-solutions.it
http://geo-solutions.blogspot.com/
http://www.youtube.com/user/GeoSolutionsIT
http://www.linkedin.com/in/andreaaime
http://twitter.com/geowolf



EditLive Enterprise is the world’s most technically advanced content
authoring tool. Experience the power of Track Changes, Inline Image
Editing and ensure content is compliant with Accessibility Checking.
http://p.sf.net/sfu/ephox-dev2dev_______________________________________________

Geoserver-users mailing list
Geoserver-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users


EditLive Enterprise is the world’s most technically advanced content
authoring tool. Experience the power of Track Changes, Inline Image
Editing and ensure content is compliant with Accessibility Checking.
http://p.sf.net/sfu/ephox-dev2dev


Geoserver-users mailing list
Geoserver-users@anonymised.comsts.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users

Thanks David, exactly what I was looking for.

-Ryan

On Jun 13, 2011, at 4:05 PM, David Winslow wrote:

You can add the listener to any applicationContext.xml, not just the one in the WFS jar. So probably the simplest way is to create a small Maven project with its own applicationContext.xml and just replace that when you want to update your listener code.

Are you calling org.geoserver.catalog.Catalog:save() on your FeatureType once the bounding box is updated? GeoServer’s catalog system has a basic transaction system and changes won’t be applied immediately upon setting properties of configuration objects.


David Winslow
OpenGeo - http://opengeo.org/

On Mon, Jun 13, 2011 at 5:00 PM, Ryan Zoerb <razoerb@anonymised.com> wrote:

I hooked up a transaction listener by adding a bean to the wfs module’s applicationContext.xml. Is there any way to hook it up in a less invasive manner? Right now I have to compile the wfs module and use it to replace the stock wfs jar in GeoServer’s WEB-INF/lib. I’d rather not replace the whole jar just to add the listener.

Also, I found what looks to be how one would update a layer’s bounding box, but I can’t get it to work. First, I get the layer’s LayerInfo from the catalog by qualified name. From the LayerInfo, I get the associated ResourceInfo, which has setLatLonBoundingBox and setNativeBoundingBox methods. I pass those the ReferencedEnvelope returned by transactionEvent.getAffectedFeatures().getBounds(). I verified that the returned bounds are correct, but the set*BoundingBox methods don’t seem to do anything. After the transaction is done, the layer’s bounds still show up as 0, 0, 0, 0 in both the GeoServer Web UI and WMS GetCaps.

Thanks again for any help,
Ryan

On Jun 10, 2011, at 12:47 PM, Ryan Zoerb wrote:

I just got around to checking out transaction listeners, and have a couple questions. First, how does one register a listener with the Spring context? Also, how does one update a layer’s bounding box from within a listener? I found this page: http://geoserver.org/display/GEOS/GSIP+14±+WFS+Transaction+handling+framework and have been looking through the wfs code, but I haven’t been able to find any more documentation or examples.

Thanks,
Ryan

On May 23, 2011, at 3:59 PM, Ryan Zoerb wrote:

Thanks for the responses Gabriel and Andrea. I need to get the bounding box of the actual feature (for zooming to the feature in OpenLayers), so I’ll give the transaction listener a try.

-Ryan

On May 23, 2011, at 11:11 AM, Andrea Aime wrote:

On Mon, May 23, 2011 at 5:50 PM, Gabriel Roldán <groldan@anonymised.com…> wrote:

I may be wrong, but my impression (biased by the meaning of the WMS
layer bounds in the spec) is that the bounds you declare for the layer
are purely informative and intend to declare what the area of validity
for the Layer/FeatureType is. In any case it has to be accurate, so a
good practice would be to set the layer bounds to the intended area of
interest for the layer to start with.
So even if a layer has no features, but represents a state wide set of
something, it’d be good to set the metadata layer bounds to the whole
state bounds, for example.
The GeoServer “calculate bounds” button is merely an utility to simplify
the common case. But IMHO you should set the bounds to the widest
possible area the layer is meant to.

I agree with Gabriel, bounds are just an indication.

That said, if you really want to do it anyways, it’s possible to roll a transaction
listener that will try to update the bounds and save them on disk to make
the change persistent.
I would suggest to do it incrementally, that is, just expand the bounds if
you see the inserted/updated feature bounds are outside of the current
layer bounds, for speed reasons.
If you want the bounds to also contract when you do a delete you’ll
have to kick a full computation against the layer contents, depending
on how large your data set it, that might be expensive if not intolerable
(computing bounds on Oracle with tens of millions of rows might
take minutes for example)

Cheers
Andrea

Ing. Andrea Aime
GeoSolutions S.A.S.
Tech lead

Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy

phone: +39 0584 962313
fax: +39 0584 962313

http://www.geo-solutions.it
http://geo-solutions.blogspot.com/
http://www.youtube.com/user/GeoSolutionsIT
http://www.linkedin.com/in/andreaaime
http://twitter.com/geowolf



EditLive Enterprise is the world’s most technically advanced content
authoring tool. Experience the power of Track Changes, Inline Image
Editing and ensure content is compliant with Accessibility Checking.
http://p.sf.net/sfu/ephox-dev2dev_______________________________________________

Geoserver-users mailing list
Geoserver-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users


EditLive Enterprise is the world’s most technically advanced content
authoring tool. Experience the power of Track Changes, Inline Image
Editing and ensure content is compliant with Accessibility Checking.
http://p.sf.net/sfu/ephox-dev2dev


Geoserver-users mailing list
Geoserver-users@anonymised.comsts.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users