You can also use a |
A LuciadFusion tile store exposes which coverages are available, and retrieve information about those coverages. For example:
-
Retrieving the ID of a coverage, which you need when you want to visualize it on a map
-
Retrieving the bounds of the coverage
-
Retrieving the geo-reference
-
…​
The following code illustrates how you can connect to a LuciadFusion tile store, find the available coverages and retrieve some information for each coverage.
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.Collections;
import java.util.List;
import com.luciad.fusion.client.ALfnClientEnvironment;
import com.luciad.fusion.client.TLfnClientFactory;
import com.luciad.fusion.core.ALfnEnvironment;
import com.luciad.fusion.tilestore.ALfnCoverage;
import com.luciad.fusion.tilestore.ALfnTileStore;
import com.luciad.fusion.tilestore.ELfnDataType;
import com.luciad.fusion.tilestore.TLfnServiceException;
import com.luciad.fusion.tilestore.TLfnTileStoreProvider;
import com.luciad.fusion.tilestore.metadata.ALfnCoverageMetadata;
import com.luciad.reference.ILcdGeoReference;
import com.luciad.shape.ILcdBounds;
final class ListAvailableCoveragesTutorial {
public static void main(String[] args) throws Exception {
// Create the environments
// These are heavy resources that you normally create once in your application and keep reusing
ALfnEnvironment environment = ALfnEnvironment.newInstance();
ALfnClientEnvironment clientEnvironment = ALfnClientEnvironment.newInstance(environment);
//Create an ALfnTileStore object
String tilestoreURL = "http://sampleservices.luciad.com/lts";
ALfnTileStore tileStore = getTileStore(tilestoreURL, clientEnvironment);
//Retrieve all the coverage IDs
List<String> coverageIds = tileStore.getCoverageIds();
Collections.sort(coverageIds);
for (String coverageID : coverageIds) {
//Retrieve the metadata for the coverage
ALfnCoverage coverage = tileStore.getCoverage(coverageID);
ALfnCoverageMetadata coverageMetadata = coverage.getMetadata();
//Retrieve some extra information
String coverageName = coverageMetadata.getName();
ELfnDataType type = coverageMetadata.getType();
String format = coverageMetadata.getFormat();
ILcdBounds bounds = coverageMetadata.getBounds();
ILcdGeoReference reference = coverageMetadata.getGeoReference();
System.out.println(coverageName);
System.out.println("ID: " + coverageID);
System.out.println("Type: " + type);
System.out.println("Format: " + format);
System.out.println("Bounds: " + bounds);
System.out.println("Reference: " + reference);
System.out.println();
}
}
private static ALfnTileStore getTileStore(String tilestoreURL, ALfnClientEnvironment aClientEnvironment) throws IOException, TLfnServiceException, URISyntaxException {
URI tileStoreUri = new URL(tilestoreURL).toURI();
TLfnClientFactory clientFactory = new TLfnClientFactory(aClientEnvironment);
TLfnTileStoreProvider tileStoreProvider = new TLfnTileStoreProvider(clientFactory, aClientEnvironment.getEnvironment());
return tileStoreProvider.getTileStore(tileStoreUri);
}
}
If you don’t need any specific information about the coverages but just want to decode some/all coverages to visualize them on a map, the code in How to find and decode (all available) coverages from a tile store can be more convenient. |