congrats Icon
New! Tabnine Pro 14-day free trial
Start a free trial
Tabnine Logo
NCNameResourceCodec
Code IndexAdd Tabnine to your IDE (free)

How to use
NCNameResourceCodec
in
org.geoserver.wcs2_0.util

Best Java code snippets using org.geoserver.wcs2_0.util.NCNameResourceCodec (Showing top 20 results out of 315)

origin: org.geoserver.extension/gs-wcs2_0-eo-core

/**
 * Returns the coverage backed by the provided datasetId
 *
 * @param datasetId
 * @return the coverage, or null if not found, or if not a coverage
 */
public CoverageInfo getDatasetCoverage(String datasetId) {
  if (!datasetId.endsWith(DATASET_SUFFIX)) {
    LOGGER.fine(
        "Invalid dataset id " + datasetId + " it does not end with " + DATASET_SUFFIX);
    return null;
  }
  String coverageName = datasetId.substring(0, datasetId.length() - DATASET_SUFFIX.length());
  LayerInfo layer = NCNameResourceCodec.getCoverage(catalog, coverageName);
  if (layer == null) {
    LOGGER.fine(
        "Invalid dataset id " + datasetId + " does not match any published dataset");
    return null;
  }
  CoverageInfo ci = (CoverageInfo) layer.getResource();
  if (!isValidDataset(ci)) {
    LOGGER.fine(
        "Invalid dataset id " + datasetId + " does not match any published dataset");
    return null;
  }
  return ci;
}
origin: org.geoserver.extension/gs-wcs2_0-eo-core

/** Builds the identifier for a granule inside a coverage */
public String getGranuleId(CoverageInfo coverage, String featureId) {
  return NCNameResourceCodec.encode(coverage) + GRANULE_SEPARATOR + featureId;
}
origin: org.geoserver/gs-wcs2_0

List<MapEntry<String, String>> decodedList = decode(encodedResourceId);
if (decodedList.isEmpty()) {
  LOGGER.info("Could not decode id '" + encodedResourceId + "'");
origin: org.geoserver/gs-wcs2_0

  LayerInfo layer = NCNameResourceCodec.getCoverage(catalog, newCoverageID);
  if (layer != null) {
    coverages.add((CoverageInfo) layer.getResource());
for (CoverageInfo ci : coverages) {
  try {
    String encodedId = NCNameResourceCodec.encode(ci);
    CoverageInfo ciNew = ci;
    String newCoverageID = covIds.get(coverageIndex);
origin: org.geoserver/gs-wcs2_0

public static LayerInfo getCoverage(Catalog catalog, String encodedCoverageId)
    throws WCS20Exception {
  List<LayerInfo> layers = NCNameResourceCodec.getLayers(catalog, encodedCoverageId);
  if (layers == null) return null;
  LayerInfo ret = null;
  for (LayerInfo layer : layers) {
    if (layer != null && layer.getType() == PublishedType.RASTER) {
      if (ret == null) {
        ret = layer;
      } else {
        LOGGER.warning(
            "Multiple coverages found for NSName '"
                + encodedCoverageId
                + "': "
                + ret.prefixedName()
                + " is selected, "
                + layer.prefixedName()
                + " will be ignored");
      }
    }
  }
  return ret;
}
origin: org.geoserver/gs-wcs2_0

@Test
public void testBasicKVP() throws Exception {
    List<LayerInfo> list0 = NCNameResourceCodec.getLayers(getCatalog(), "pippo_topo");
    assertNotNull(list0);
    assertEquals(0, list0.size());
    List<LayerInfo> list1 = NCNameResourceCodec.getLayers(getCatalog(), "pippo__topo");
    assertNotNull(list1);
    assertEquals(0, list1.size());
    List<LayerInfo> list = NCNameResourceCodec.getLayers(getCatalog(), "wcs__BlueMarble");
    assertNotNull(list);
    assertEquals(1, list.size());
    WorkspaceInfo oldWs = LocalWorkspace.get();
    LocalWorkspace.set(ws);
    List<LayerInfo> list = NCNameResourceCodec.getLayers(getCatalog(), "BlueMarble");
    assertNotNull(list);
    assertEquals(1, list.size());
    List<LayerInfo> list = NCNameResourceCodec.getLayers(getCatalog(), "BlueMarble");
    assertNotNull(list);
    assertEquals(1, list.size());
origin: org.geoserver.extension/gs-wcs2_0-eo-core

/**
 * Returns the coverage containing the specified coverage, or null if the syntax is incorrect,
 * the coverage does not exist, or it's not a dataset
 */
public CoverageInfo getGranuleCoverage(String granuleId) {
  // does it have the expected lexical structure?
  if (!granuleId.contains(GRANULE_SEPARATOR)) {
    return null;
  }
  String[] splitted = granuleId.split(GRANULE_SEPARATOR);
  if (splitted.length != 2) {
    return null;
  }
  // do we have the coverage?
  LayerInfo li = NCNameResourceCodec.getCoverage(catalog, splitted[0]);
  if (li == null) {
    return null;
  }
  // is it a EO dataset?
  CoverageInfo ci = (CoverageInfo) li.getResource();
  if (isValidDataset(ci)) {
    return ci;
  } else {
    return null;
  }
}
origin: org.geoserver.extension/gs-wcs2_0-eo-core

public String getDatasetName(CoverageInfo ci) {
  if (!isValidDataset(ci)) {
    throw new IllegalArgumentException(
        "Specified covearge " + ci.prefixedName() + " is not a valid EO dataset");
  }
  return NCNameResourceCodec.encode(ci) + DATASET_SUFFIX;
}
origin: org.geoserver/gs-wcs2_0

@Test
public void testDecode01() {
  String qualifiedName = "ws__name";
  List<MapEntry<String, String>> decode = NCNameResourceCodec.decode(qualifiedName);
  assertEquals(1, decode.size());
  assertEquals("ws", decode.get(0).getKey());
  assertEquals("name", decode.get(0).getValue());
}
origin: org.geoserver.extension/gs-netcdf-out

if (geoserver != null) {
  Catalog gsCatalog = geoserver.getCatalog();
  LayerInfo info = NCNameResourceCodec.getCoverage(gsCatalog, coverageId);
  if (info != null) {
    map = info.getResource().getMetadata();
origin: org.geoserver/gs-wcs2_0

/**
 * Base constructor which only deals with timeDimension. It is used by WCS-EO classes which
 * deals with up to timeDimensions
 *
 * @param timeDimension
 * @param reader
 * @param coverageId
 * @throws IOException
 */
public WCSDimensionsHelper(CoverageInfo ci) throws IOException {
  this.coverageId = NCNameResourceCodec.encode(ci);
  this.accessor =
      new ReaderDimensionsAccessor(
          (GridCoverage2DReader) ci.getGridCoverageReader(null, null));
  Map<String, DimensionInfo> dimensions = new HashMap<String, DimensionInfo>();
  for (Map.Entry<String, Serializable> entry : ci.getMetadata().entrySet()) {
    if (entry.getValue() instanceof DimensionInfo) {
      dimensions.put(entry.getKey(), (DimensionInfo) entry.getValue());
    }
  }
  if (!dimensions.isEmpty()) {
    initDimensions(dimensions);
  }
}
origin: org.geoserver/gs-wcs2_0

  @Test // (expected=IllegalArgumentException.class)
  public void testDecodeBad() {
    String qualifiedName = "bad_qualified_name";
    List<MapEntry<String, String>> decode = NCNameResourceCodec.decode(qualifiedName);
    assertEquals(1, decode.size());
    assertNull(decode.get(0).getKey());
    assertEquals("bad_qualified_name", decode.get(0).getValue());
  }
}
origin: org.geoserver.community/gs-netcdf-out

if (geoserver != null) {
  Catalog gsCatalog = geoserver.getCatalog();
  LayerInfo info = NCNameResourceCodec.getCoverage(gsCatalog, coverageId);
  if (info != null) {
    map = info.getResource().getMetadata();
origin: org.geoserver/gs-wcs2_0

public static String encode(ResourceInfo resource) {
  return encode(resource.getNamespace().getPrefix(), resource.getName());
}
origin: org.geoserver/gs-wcs2_0

@Test
public void testDecode03() {
  String qualifiedName = "s1___s2";
  List<MapEntry<String, String>> decode = NCNameResourceCodec.decode(qualifiedName);
  assertEquals(2, decode.size());
  assertEquals("s1_", decode.get(0).getKey());
  assertEquals("s2", decode.get(0).getValue());
  assertEquals("s1", decode.get(1).getKey());
  assertEquals("_s2", decode.get(1).getValue());
}
origin: org.geoserver/gs-wcs2_0

LayerInfo layer = NCNameResourceCodec.getCoverage(catalog, newCoverageID);
if (layer == null) {
  badCoverageIds.add(encodedCoverageId);
origin: org.geoserver/gs-wcs2_0

/** Test of encode method, of class CoverageIdConverter. */
@Test
public void testEncode() {
  String result = NCNameResourceCodec.encode("ws", "name");
  assertEquals("ws__name", result);
}
origin: org.geoserver/gs-wcs2_0

@Test
public void testDecode02() {
  String qualifiedName = "s1__s2__s3";
  List<MapEntry<String, String>> decode = NCNameResourceCodec.decode(qualifiedName);
  assertEquals(2, decode.size());
  assertEquals("s1__s2", decode.get(0).getKey());
  assertEquals("s3", decode.get(0).getValue());
  assertEquals("s1", decode.get(1).getKey());
  assertEquals("s2__s3", decode.get(1).getValue());
}
origin: org.geoserver.extension/gs-netcdf-out

  /**
   * Extracts the NetCDF encoding settings from the coverage identifier
   *
   * @param coverageId
   * @return
   */
  static NetCDFLayerSettingsContainer getSettings(String coverageId) {
    GeoServer geoserver = GeoServerExtensions.bean(GeoServer.class);
    MetadataMap map = null;
    if (geoserver != null) {
      Catalog gsCatalog = geoserver.getCatalog();
      LayerInfo info = NCNameResourceCodec.getCoverage(gsCatalog, coverageId);
      if (info != null) {
        map = info.getResource().getMetadata();
      }
    }
    if (map != null
        && !map.isEmpty()
        && map.containsKey(NetCDFSettingsContainer.NETCDFOUT_KEY)) {
      NetCDFLayerSettingsContainer settings =
          (NetCDFLayerSettingsContainer)
              map.get(
                  NetCDFSettingsContainer.NETCDFOUT_KEY,
                  NetCDFLayerSettingsContainer.class);
      return settings;
    }

    return null;
  }
}
origin: org.geoserver/gs-wcs2_0

private void handleCoverageSummary(CoverageInfo cv) throws Exception {
  start("wcs:CoverageSummary");
  String covId = NCNameResourceCodec.encode(cv);
  element("wcs:CoverageId", covId);
  element("wcs:CoverageSubtype", "RectifiedGridCoverage"); // TODO make this parametric
  handleWGS84BoundingBox(cv.getLatLonBoundingBox());
  handleBoundingBox(cv.boundingBox());
  end("wcs:CoverageSummary");
}
org.geoserver.wcs2_0.utilNCNameResourceCodec

Javadoc

De/encode a workspace and a resource name into a single string.

Some external formats do not allow to use semicolons in some strings. This class offers methods to encode and decode workspace and names into a single string without using semicolons.

We simply use a "__" as separator. This should reduce the conflicts with existing underscores. This encoding is not unique, so the #decode(java.lang.String) method return a list of possible workspace,name combinations. You'll need to check which workspace is really existing.

You may use the #getLayer(org.geoserver.catalog.Catalog,java.lang.String)method to just retrieve the matching layers.

Most used methods

  • getCoverage
  • encode
  • decode
  • getLayers
    Search in the catalog the Layers matching the encoded id.

Popular in Java

  • Parsing JSON documents to java classes using gson
  • getResourceAsStream (ClassLoader)
  • getExternalFilesDir (Context)
  • setScale (BigDecimal)
  • HttpServer (com.sun.net.httpserver)
    This class implements a simple HTTP server. A HttpServer is bound to an IP address and port number a
  • List (java.util)
    An ordered collection (also known as a sequence). The user of this interface has precise control ove
  • TreeMap (java.util)
    Walk the nodes of the tree left-to-right or right-to-left. Note that in descending iterations, next
  • ServletException (javax.servlet)
    Defines a general exception a servlet can throw when it encounters difficulty.
  • Response (javax.ws.rs.core)
    Defines the contract between a returned instance and the runtime when an application needs to provid
  • DateTimeFormat (org.joda.time.format)
    Factory that creates instances of DateTimeFormatter from patterns and styles. Datetime formatting i
  • Top 25 Plugins for Webstorm
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now