This repository was archived by the owner on Dec 30, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 196
Recalculate Bounding Boxes #200
Open
cschroedl-gov
wants to merge
12
commits into
geosolutions-it:master
Choose a base branch
from
cschroedl-gov:master-199-recalculate-feature-type-bounding-boxes
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 4 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
8496756
First cut of private implementation for #199
cschroedl-gov c9ef31f
Added public wrapper methods #199
cschroedl-gov ce3ee33
Fixed silent error due to url case-sensitivity. Adjusted request body…
cschroedl-gov e218762
Switching to formal XML body construction via GS*Encoder classes. #199
cschroedl-gov cd51198
Revert "Switching to formal XML body construction via GS*Encoder clas…
cschroedl-gov 6b77579
Cleanup #199
cschroedl-gov 53b602e
Prevented setup from running outside of integration tests.
cschroedl-gov 9c5fd05
Doc improvement
cschroedl-gov f251419
Revert "Revert "Switching to formal XML body construction via GS*Enco…
cschroedl-gov 5163af6
Adding recursive child xml node deletion to support GS*Encoder-centri…
cschroedl-gov 769db7f
Eliminating empty methods.
cschroedl-gov bf2e203
Cleaned up documentation, eliminated unused imports and useless metho…
cschroedl-gov File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
107 changes: 107 additions & 0 deletions
107
src/test/java/it/geosolutions/geoserver/rest/publisher/GeoserverRESTRecalculateTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,107 @@ | ||
| /* | ||
| * GeoServer-Manager - Simple Manager Library for GeoServer | ||
| * | ||
| * Copyright (C) 2007,2011 GeoSolutions S.A.S. | ||
| * http://www.geo-solutions.it | ||
| * | ||
| * Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| * of this software and associated documentation files (the "Software"), to deal | ||
| * in the Software without restriction, including without limitation the rights | ||
| * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| * copies of the Software, and to permit persons to whom the Software is | ||
| * furnished to do so, subject to the following conditions: | ||
| * | ||
| * The above copyright notice and this permission notice shall be included in | ||
| * all copies or substantial portions of the Software. | ||
| * | ||
| * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
| * THE SOFTWARE. | ||
| */ | ||
|
|
||
| package it.geosolutions.geoserver.rest.publisher; | ||
|
|
||
| import it.geosolutions.geoserver.rest.GeoServerRESTPublisher; | ||
| import it.geosolutions.geoserver.rest.GeoServerRESTPublisher.StoreType; | ||
| import it.geosolutions.geoserver.rest.GeoServerRESTPublisher.UploadMethod; | ||
| import it.geosolutions.geoserver.rest.GeoserverRESTTest; | ||
| import it.geosolutions.geoserver.rest.decoder.RESTLayer; | ||
| import it.geosolutions.geoserver.rest.encoder.GSResourceEncoder.ProjectionPolicy; | ||
| import it.geosolutions.geoserver.rest.encoder.coverage.GSCoverageEncoderTest; | ||
|
|
||
| import java.io.File; | ||
| import java.io.FileNotFoundException; | ||
| import java.io.IOException; | ||
|
|
||
| import org.apache.commons.httpclient.NameValuePair; | ||
| import org.junit.After; | ||
| import org.junit.Test; | ||
| import static org.junit.Assert.*; | ||
| import org.junit.Before; | ||
| import org.slf4j.Logger; | ||
| import org.slf4j.LoggerFactory; | ||
| import org.springframework.core.io.ClassPathResource; | ||
|
|
||
| /** | ||
| * Testcase for publishing layers on geoserver. | ||
| * We need a running GeoServer to properly run the tests. | ||
| * If such geoserver instance cannot be contacted, tests will be skipped. | ||
| * | ||
| * @author Carl Schroedl - cschroedl@usgs.gov | ||
| */ | ||
| public class GeoserverRESTRecalculateTest extends GeoserverRESTTest { | ||
|
|
||
| private final static Logger LOGGER = LoggerFactory.getLogger(GeoserverRESTRecalculateTest.class); | ||
|
|
||
| @Before | ||
| @Override | ||
| public void before(){ | ||
| super.before(); | ||
| deleteAll(); | ||
| assertTrue(publisher.createWorkspace(DEFAULT_WS)); | ||
| } | ||
|
|
||
| @After | ||
| public void cleanUp(){ | ||
| deleteAll(); | ||
| } | ||
|
|
||
| @Test | ||
| public void testRecalculateFeatureTypeBBox() throws FileNotFoundException, IOException { | ||
| if (!enabled()) | ||
| return; | ||
|
|
||
| String storeName = "resttestshp"; | ||
| String layerName = "cities"; | ||
|
|
||
| File zipFile = new ClassPathResource("testdata/resttestshp.zip").getFile(); | ||
| assertTrue(publisher.publishShp(DEFAULT_WS, storeName, layerName, zipFile)); | ||
|
|
||
| for(GeoServerRESTPublisher.BBoxRecalculationMode recalcMode : GeoServerRESTPublisher.BBoxRecalculationMode.values()){ | ||
| boolean recalculated = publisher.recalculateFeatureTypeBBox(DEFAULT_WS,storeName, layerName, recalcMode, true); | ||
| assertTrue("recalculateBBox failed with recalculation mode '" +recalcMode.toString() + "'.", recalculated); | ||
| } | ||
| } | ||
|
|
||
| @Test | ||
| public void testRecalculateCoverageBBox() throws FileNotFoundException, IOException { | ||
| if (!enabled()) | ||
| return; | ||
|
|
||
| String storeName = "testRESTStoreArcGrid"; | ||
| String layerName = "resttestdem"; | ||
|
|
||
| File arcgrid = new ClassPathResource("testdata/resttestdem.asc").getFile(); | ||
|
|
||
| assertTrue(publisher.publishArcGrid(DEFAULT_WS, storeName, layerName, arcgrid)); | ||
|
|
||
| for(GeoServerRESTPublisher.BBoxRecalculationMode recalcMode : GeoServerRESTPublisher.BBoxRecalculationMode.values()){ | ||
| boolean recalculated = publisher.recalculateCoverageBBox(DEFAULT_WS,storeName, layerName, recalcMode, true); | ||
| assertTrue("recalculateBBox failed with recalculation mode '" +recalcMode.toString() + "'.", recalculated); | ||
| } | ||
| } | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update: never mind! After adding a method to XmlElement to recursively delete empty children, I was able to use the GS*Encoder classes instead of building the xml with Strings.
When I switched to using GSEncoder classes, I noted that several extra elements were added to the resulting XML documents. These extra empty elements could overwrite existing keywords, metadata, and metadatalinks. While I can remove a hard-coded list of extra elements now, the same kind of problem can occur in the future if new fields are added to the encoders without updating this class. I opted to revert to simple String construction instead of GSEncoder classes to ensure that this functionality would continue to be stable in the future.