/** Visit all files to keep only XML files. */ @Override protected void visit() { final ParameterValue<URL> paramUrl = (ParameterValue<URL>) getSourceConfiguration(getSource()).parameter(URL.getName().getCode()); if (paramUrl == null || paramUrl.getValue() == null) { getLogger().log(Level.WARNING, "Provided File path is not defined."); return; } final URL urlPath = paramUrl.getValue(); try { path = new File(urlPath.toURI()); } catch (URISyntaxException e) { getLogger().log(Level.INFO, "Fails to convert path url to file."); path = new File(urlPath.getPath()); } List<File> candidates = new ArrayList<>(); if (path.isDirectory()) { candidates.addAll( FileUtilities.scanDirectory( path, new FileFilter() { @Override public boolean accept(File pathname) { final String fullName = pathname.getName(); final int idx = fullName.lastIndexOf('.'); final String extension = fullName.substring(idx + 1); return extension.equalsIgnoreCase("xml"); } })); } else { candidates.add(path); } index = new HashMap<>(); for (final File candidate : candidates) { try { final MapContext mapContext = MapContextIO.readMapContextFile(candidate, "", "", styleBusiness); if (mapContext != null) { final GenericName name = NamesExt.create(mapContext.getName()); index.put(name, candidate); } } catch (JAXBException e) { getLogger() .log( Level.WARNING, "Candidate MapContext file can't be read : " + candidate.getAbsolutePath(), e); } } super.visit(); }
/** * Class Description * * @author Alexis Manin (Geomatys) Date : 27/02/13 */ public class LabelLine implements MIFSymbolizer { public static final GenericName NAME = NamesExt.create("LABEL"); public static final Pattern PATTERN = Pattern.compile(NAME.tip().toString(), Pattern.CASE_INSENSITIVE); private String type = "simple"; private Coordinate point; public LabelLine(String lineType, Coordinate pt) { type = lineType; point = pt; } @Override public String toMIFText() { return NAME.tip().toString() + ' ' + type + ' ' + point.x + ' ' + point.y; } @Override public Unit<Length> getUnitOfMeasure() { throw new UnsupportedOperationException("No implementation exists for this method."); } @Override public String getGeometryPropertyName() { throw new UnsupportedOperationException("No implementation exists for this method."); } @Override public Expression getGeometry() { return FactoryFinder.getFilterFactory(null).property(getGeometryPropertyName()); } @Override public String getName() { return NAME.tip().toString(); } @Override public Description getDescription() { throw new UnsupportedOperationException("No implementation exists for this method."); } @Override public Object accept(StyleVisitor styleVisitor, Object o) { throw new UnsupportedOperationException("No implementation exists for this method."); } @Override public String toString() { return toMIFText(); } }
@Override public synchronized DataNode getRootNode() throws DataStoreException { if (rootNode == null) { rootNode = new DefaultDataNode(); final AbstractWMSCapabilities capa; try { capa = getCapabilities(); } catch (CapabilitiesException ex) { throw new DataStoreException(ex); } final List<AbstractLayer> layers = capa.getLayers(); for (AbstractLayer al : layers) { final String name = al.getName(); if (name != null) { final GenericName nn = NamesExt.valueOf(name); final CoverageReference ref = createReference(nn); rootNode.getChildren().add(ref); } } } return rootNode; }
public static FeatureReader wrap(FeatureReader reader, final Query remainingParameters) throws DataStoreException { final Integer start = remainingParameters.getStartIndex(); final Integer max = remainingParameters.getMaxFeatures(); final Filter filter = remainingParameters.getFilter(); final GenericName[] properties = remainingParameters.getPropertyNames(); final SortBy[] sorts = remainingParameters.getSortBy(); final double[] resampling = remainingParameters.getResolution(); final CoordinateReferenceSystem crs = remainingParameters.getCoordinateSystemReproject(); final Hints hints = remainingParameters.getHints(); // we should take care of wrapping the reader in a correct order to avoid // unnecessary calculations. fast and reducing number wrapper should be placed first. // but we must not take misunderstanding assumptions neither. // exemple : filter is slow than startIndex and MaxFeature but must be placed before // otherwise the result will be illogic. // wrap sort by --------------------------------------------------------- // This can be really expensive, and force the us to read the full iterator. // that may cause out of memory errors. if (sorts != null && sorts.length != 0) { reader = GenericSortByFeatureIterator.wrap(reader, sorts); } // wrap filter ---------------------------------------------------------- // we must keep the filter first since it impacts the start index and max feature if (filter != null && filter != Filter.INCLUDE) { if (filter == Filter.EXCLUDE) { // filter that exclude everything, use optimzed reader reader = GenericEmptyFeatureIterator.createReader(reader.getFeatureType()); // close original reader reader.close(); } else { reader = GenericFilterFeatureIterator.wrap(reader, filter); } } // wrap start index ----------------------------------------------------- if (start != null && start > 0) { reader = GenericStartIndexFeatureIterator.wrap(reader, start); } // wrap max ------------------------------------------------------------- if (max != null) { if (max == 0) { // use an optimized reader reader = GenericEmptyFeatureIterator.createReader(reader.getFeatureType()); // close original reader reader.close(); } else { reader = GenericMaxFeatureIterator.wrap(reader, max); } } // wrap properties, remove primary keys if necessary -------------------- final Boolean hide = (Boolean) hints.get(HintsPending.FEATURE_HIDE_ID_PROPERTY); final FeatureType original = reader.getFeatureType(); FeatureType mask = original; if (properties != null) { final List<GenericName> names = new ArrayList<GenericName>(); loop: for (GenericName n : properties) { for (GenericName dn : names) { if (NamesExt.match(n, dn)) continue loop; } names.add(n); } try { mask = FeatureTypeUtilities.createSubType(mask, names.toArray(new GenericName[0])); } catch (MismatchedFeatureException ex) { throw new DataStoreException(ex); } } if (hide != null && hide) { try { // remove primary key properties mask = FeatureTypeUtilities.excludePrimaryKeyFields(mask); } catch (MismatchedFeatureException ex) { throw new DataStoreException(ex); } } if (mask != original) { reader = GenericRetypeFeatureIterator.wrap(reader, mask, hints); } // wrap resampling ------------------------------------------------------ if (resampling != null) { reader = GenericTransformFeatureIterator.wrap( reader, new GeometryScaleTransformer(resampling[0], resampling[1]), hints); } // wrap reprojection ---------------------------------------------------- if (crs != null) { try { reader = GenericReprojectFeatureIterator.wrap(reader, crs, hints); } catch (FactoryException ex) { throw new DataStoreException(ex); } catch (MismatchedFeatureException ex) { throw new DataStoreException(ex); } } return reader; }