-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add FeatureUrlFunction and LoadingStrategy support
- Loading branch information
1 parent
813ae6e
commit a60f5b4
Showing
6 changed files
with
168 additions
and
0 deletions.
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
gwt-ol3-client/src/main/java/ol/loadingstrategy/LoadingStrategy.java
This file contains 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,42 @@ | ||
/******************************************************************************* | ||
* Copyright 2014, 2023 gwt-ol | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*******************************************************************************/ | ||
package ol.loadingstrategy; | ||
|
||
import jsinterop.annotations.JsOverlay; | ||
import jsinterop.annotations.JsProperty; | ||
import jsinterop.annotations.JsType; | ||
|
||
|
||
@JsType(isNative = true) | ||
public class LoadingStrategy { | ||
|
||
@JsOverlay | ||
private static final String PACKAGE_LOADING_STRATEGY = "ol.loadingstrategy"; | ||
|
||
/** | ||
* @return Strategy function for loading all features with a single request. | ||
*/ | ||
@JsProperty(name = "all", namespace = PACKAGE_LOADING_STRATEGY) | ||
public static native LoadingStrategyFunction getAll(); | ||
|
||
/** | ||
* @return Strategy function for loading features based on the view's extent and | ||
* resolution. | ||
*/ | ||
@JsProperty(name = "bbox", namespace = PACKAGE_LOADING_STRATEGY) | ||
public static native LoadingStrategyFunction getBbox(); | ||
|
||
} |
33 changes: 33 additions & 0 deletions
33
gwt-ol3-client/src/main/java/ol/loadingstrategy/LoadingStrategyFunction.java
This file contains 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,33 @@ | ||
/******************************************************************************* | ||
* Copyright 2014, 2023 gwt-ol | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*******************************************************************************/ | ||
package ol.loadingstrategy; | ||
|
||
import jsinterop.annotations.JsFunction; | ||
import ol.Extent; | ||
|
||
@FunctionalInterface | ||
@JsFunction | ||
public interface LoadingStrategyFunction { | ||
|
||
/** | ||
* | ||
* @param extent | ||
* @param resolution | ||
* @return | ||
*/ | ||
Extent[] getExtents(Extent extent, double resolution); | ||
|
||
} |
38 changes: 38 additions & 0 deletions
38
gwt-ol3-client/src/main/java/ol/source/FeatureUrlFunction.java
This file contains 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,38 @@ | ||
/******************************************************************************* | ||
* Copyright 2014, 2023 gwt-ol | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*******************************************************************************/ | ||
package ol.source; | ||
|
||
import jsinterop.annotations.JsFunction; | ||
import ol.Extent; | ||
import ol.proj.Projection; | ||
|
||
/** | ||
* | ||
* | ||
* {@link ol.source.Vector} sources use a function of this type to get the url to load features from. | ||
*/ | ||
@FunctionalInterface | ||
@JsFunction | ||
public interface FeatureUrlFunction { | ||
|
||
/** | ||
* @param extent area to be loaded | ||
* @param resolution resolution (map units per pixel) | ||
* @param projection projection | ||
* @return URL | ||
*/ | ||
String getUrl(Extent extent, double resolution, Projection projection); | ||
} |
This file contains 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 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
39 changes: 39 additions & 0 deletions
39
gwt-ol3-client/src/test/java/ol/loadingstrategy/LoadingStrategyTest.java
This file contains 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,39 @@ | ||
/******************************************************************************* | ||
* Copyright 2014, 2023 gwt-ol | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*******************************************************************************/ | ||
package ol.loadingstrategy; | ||
|
||
import ol.GwtOLBaseTestCase; | ||
|
||
/** | ||
* Test for loading strategies. | ||
* | ||
* @author TDesjardins | ||
* | ||
*/ | ||
public class LoadingStrategyTest extends GwtOLBaseTestCase { | ||
|
||
public void testLoadinStrategy() { | ||
|
||
this.injectUrlAndTest(() -> { | ||
|
||
assertNotNull(LoadingStrategy.getAll()); | ||
assertNotNull(LoadingStrategy.getBbox()); | ||
|
||
}); | ||
|
||
} | ||
|
||
} |