本文整理汇总了Java中org.geotools.data.DataSourceException类的典型用法代码示例。如果您正苦于以下问题:Java DataSourceException类的具体用法?Java DataSourceException怎么用?Java DataSourceException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DataSourceException类属于org.geotools.data包,在下文中一共展示了DataSourceException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: collection
import org.geotools.data.DataSourceException; //导入依赖的package包/类
@Override
public FeatureCollection collection() throws IOException {
final FeatureCollection copy = new SOSFeatureCollection(null,
featureType);
final List<Feature> list = new ArrayList<Feature>(contents.size());
for (final FeatureIterator iterator = features(); iterator.hasNext();) {
final Feature feature = iterator.next();
Feature duplicate;
try {
duplicate = feature.getFeatureType().duplicate(feature);
} catch (final IllegalAttributeException e) {
throw new DataSourceException("Unable to copy "
+ feature.getID(), e);
}
list.add(duplicate);
}
copy.addAll(list);
return copy;
}
开发者ID:52North,项目名称:uDig-SOS-plugin,代码行数:20,代码来源:SOSFeatureCollection.java
示例2: next
import org.geotools.data.DataSourceException; //导入依赖的package包/类
/**
* Retrieve the next line.
*
* @throws IOException
* @throws NoSuchElementException
*/
public void next() throws IOException {
if (hasNext()) {
line = next;
next = null;
int split = line.indexOf('=');
fid = line.substring(0, split);
text = line.substring(split + 1).split("\\|");
if (type.getAttributeCount() != text.length)
throw new DataSourceException("format error: expected "
+ type.getAttributeCount() + " attributes, but found "
+ text.length + ". [" + line + "]");
} else {
throw new NoSuchElementException();
}
}
开发者ID:ianturton,项目名称:geotools-cookbook,代码行数:23,代码来源:PropertyAttributeReader.java
示例3: makeDefinitionQuery
import org.geotools.data.DataSourceException; //导入依赖的package包/类
/**
* Takes a query and adapts it to match re definitionQuery filter
* configured for a feature type.
*
* @param query Query against this DataStore
* @param schema TODO
*
* @return Query restricted to the limits of definitionQuery
*
* @throws IOException See DataSourceException
* @throws DataSourceException If query could not meet the restrictions of
* definitionQuery
*/
protected Query makeDefinitionQuery(Query query, SimpleFeatureType schema) throws IOException {
if ((query == Query.ALL) || query.equals(Query.ALL)) {
return query;
}
try {
String[] propNames = extractAllowedAttributes(query, schema);
Filter filter = query.getFilter();
filter = makeDefinitionFilter(filter);
Query defQuery = new Query(query);
defQuery.setFilter(filter);
defQuery.setPropertyNames(propNames);
// set sort by
if (query.getSortBy() != null) {
defQuery.setSortBy(query.getSortBy());
}
// tell the data sources about the default linearization tolerance for curved
// geometries they might be reading
if (linearizationTolerance != null) {
query.getHints().put(Hints.LINEARIZATION_TOLERANCE, linearizationTolerance);
}
return defQuery;
} catch (Exception ex) {
throw new DataSourceException(
"Could not restrict the query to the definition criteria: " + ex.getMessage(), ex);
}
}
开发者ID:STEMLab,项目名称:geoserver-3d-extension,代码行数:45,代码来源:ISOGeoServerFeatureSource.java
示例4: makeDefinitionFilter
import org.geotools.data.DataSourceException; //导入依赖的package包/类
/**
* If a definition query has been configured for the FeatureTypeInfo, makes
* and return a new Filter that contains both the query's filter and the
* layer's definition one, by logic AND'ing them.
*
* @param filter Origional user supplied Filter
*
* @return Filter adjusted to the limitations of definitionQuery
*
* @throws DataSourceException If the filter could not meet the limitations
* of definitionQuery
*/
protected Filter makeDefinitionFilter(Filter filter)
throws DataSourceException {
Filter newFilter = filter;
try {
if (definitionQuery != Filter.INCLUDE) {
newFilter = ff.and(definitionQuery, filter);
}
} catch (Exception ex) {
throw new DataSourceException("Can't create the definition filter", ex);
}
return newFilter;
}
开发者ID:STEMLab,项目名称:geoserver-3d-extension,代码行数:27,代码来源:ISOGeoServerFeatureSource.java
示例5: getSchema
import org.geotools.data.DataSourceException; //导入依赖的package包/类
/**
* Creates a Schema (FeatureType) from the first line of the .properties
* file
*
* @param typeName TypeName indicating the property file used
*/
public SimpleFeatureType getSchema(String typeName) throws IOException {
String typeSpec = property(typeName, "_");
try {
String namespace = directory.getName();
return DataUtilities.createType(namespace + "." + typeName,
typeSpec);
} catch (SchemaException e) {
e.printStackTrace();
throw new DataSourceException(typeName + " schema not available", e);
}
}
开发者ID:ianturton,项目名称:geotools-cookbook,代码行数:18,代码来源:PropertyDataStore.java
示例6: PropertyAttributeReader
import org.geotools.data.DataSourceException; //导入依赖的package包/类
/**
* Creates a new PropertyAttributeReader object.
*
* @param file File being read
* @throws IOException
* @throws DataSourceException
*/
public PropertyAttributeReader(File file) throws IOException {
String typeName = typeName(file);
String namespace = namespace(file);
reader = new BufferedReader(new FileReader(file));
// read until "_=";
while ((line = reader.readLine()) != null) {
if (line.startsWith("_="))
break;
}
if ((line == null) || !line.startsWith("_=")) {
throw new IOException(typeName + " schema not available");
}
String typeSpec = line.substring(2);
try {
type = DataUtilities.createType(namespace, typeName, typeSpec);
} catch (SchemaException e) {
throw new DataSourceException(typeName + " schema not available", e);
}
line = null;
next = null;
}
开发者ID:ianturton,项目名称:geotools-cookbook,代码行数:34,代码来源:PropertyAttributeReader.java
示例7: GeoWaveRasterReader
import org.geotools.data.DataSourceException; //导入依赖的package包/类
public GeoWaveRasterReader(
final GeoWaveRasterConfig config )
throws DataSourceException {
super(
new Object(),
new Hints());
this.config = config;
init(config);
}
开发者ID:locationtech,项目名称:geowave,代码行数:10,代码来源:GeoWaveRasterReader.java
示例8: read
import org.geotools.data.DataSourceException; //导入依赖的package包/类
/**
* @see org.geotools.data.jdbc.attributeio.AttributeIO#read(java.sql.ResultSet,
* int)
*/
public Object read(ResultSet rs, String columnName) throws IOException {
try {
String wkt = rs.getString(columnName);
if (wkt == null) // ie. its a null column -> return a null geometry!
return null;
return wkb2Geometry(wkt);
} catch (SQLException e) {
throw new DataSourceException("SQL exception occurred while reading the geometry.", e);
}
}
开发者ID:DennisPallett,项目名称:gt-jdbc-monetdb,代码行数:15,代码来源:WKTAttributeIO.java
示例9: write
import org.geotools.data.DataSourceException; //导入依赖的package包/类
/**
* @see org.geotools.data.jdbc.attributeio.AttributeIO#write(java.sql.PreparedStatement, int, java.lang.Object)
* @TODO fix for wkt
*/
public void write(PreparedStatement ps, int position, Object value) throws IOException {
try {
if(value == null) {
ps.setNull(position, Types.OTHER);
} else {
ps.setBytes( position, new WKBWriter().write( (Geometry)value ));
}
} catch (SQLException e) {
throw new DataSourceException("SQL exception occurred while reading the geometry.", e);
}
}
开发者ID:DennisPallett,项目名称:gt-jdbc-monetdb,代码行数:17,代码来源:WKTAttributeIO.java
示例10: reprojectFilter
import org.geotools.data.DataSourceException; //导入依赖的package包/类
private Query reprojectFilter(Query query) throws IOException {
SimpleFeatureType nativeFeatureType = source.getSchema();
final GeometryDescriptor geom = nativeFeatureType.getGeometryDescriptor();
// if no geometry involved, no reprojection needed
if(geom == null)
return query;
try {
// default CRS: the CRS we can assume geometry and bbox elements in filter are
// that is, usually the declared one, but the native one in the leave case
CoordinateReferenceSystem defaultCRS = null;
// we need to reproject all bbox and geometries to a target crs, which is
// the native one usually, but it's the declared on in the force case (since in
// that case we completely ignore the native one)
CoordinateReferenceSystem targetCRS = null;
CoordinateReferenceSystem nativeCRS = geom.getCoordinateReferenceSystem();
if(srsHandling == ProjectionPolicy.FORCE_DECLARED) {
defaultCRS = declaredCRS;
targetCRS = declaredCRS;
nativeFeatureType = FeatureTypes.transform(nativeFeatureType, declaredCRS);
} else if(srsHandling == ProjectionPolicy.REPROJECT_TO_DECLARED) {
defaultCRS = declaredCRS;
targetCRS = nativeCRS;
} else { // FeatureTypeInfo.LEAVE
defaultCRS = nativeCRS;
targetCRS = nativeCRS;
}
// now we apply a default to all geometries and bbox in the filter
ISODefaultCRSFilterVisitor defaultCRSVisitor = new ISODefaultCRSFilterVisitor(ff, defaultCRS);
Filter filter = query.getFilter() != null ? query.getFilter() : Filter.INCLUDE;
Filter defaultedFilter = (Filter) filter.accept(defaultCRSVisitor, null);
// and then we reproject all geometries so that the datastore receives
// them in the native projection system (or the forced one, in case of force)
ISOReprojectingFilterVisitor reprojectingVisitor = new ISOReprojectingFilterVisitor(ff, nativeFeatureType);
Filter reprojectedFilter = (Filter) defaultedFilter.accept(reprojectingVisitor, null);
Query reprojectedQuery = new Query(query);
reprojectedQuery.setFilter(reprojectedFilter);
return reprojectedQuery;
} catch(Exception e) {
throw new DataSourceException("Had troubles handling filter reprojection...", e);
}
}
开发者ID:STEMLab,项目名称:geoserver-3d-extension,代码行数:46,代码来源:ISOGeoServerFeatureSource.java
示例11: generateOverviews
import org.geotools.data.DataSourceException; //导入依赖的package包/类
/**
* @param retValue
* @return the number of steps processed, or 0 if none was done, or -1 on error.
* @throws DataSourceException
*/
public static int generateOverviews(AbstractGridCoverage2DReader abstractGridCoverage2DReader)
throws DataSourceException {
final File geotiffFile = (File) abstractGridCoverage2DReader.getSource();
// ////
// Adding Overviews
// ////
int tileH = 512;
int tileW = 512;
/** computing the number of steps **/
GridEnvelope gridRange = abstractGridCoverage2DReader.getOriginalGridRange();
int height = gridRange.getSpan(1);
int width = gridRange.getSpan(0);
int ratioH = (int) Math.ceil((1.0 * height) / tileH);
int ratioW = (int) Math.ceil((1.0 * width) / tileW);
int nStepsH = 0;
int nStepsW = 0;
if (ratioH >= 2) {
nStepsH = (int) Math.floor(Math.log(ratioH) / Math.log(2));
}
if (ratioW >= 2) {
nStepsW = (int) Math.floor(Math.log(ratioW) / Math.log(2));
}
int numSteps = Math.min(nStepsH, nStepsW);
int downSampleSteps = 2;
if (numSteps > 0) {
final OverviewsEmbedder oe = new OverviewsEmbedder();
oe.setDownsampleStep(downSampleSteps);
oe.setNumSteps(numSteps);
oe.setScaleAlgorithm(OverviewsEmbedder.SubsampleAlgorithm.Nearest.toString());
oe.setTileCache(JAI.getDefaultInstance().getTileCache());
// oe.setTileHeight(tileH);
// oe.setTileWidth(tileW);
oe.setSourcePath(geotiffFile.getAbsolutePath());
EmbedderListener listener = new EmbedderListener(geotiffFile.getAbsolutePath());
// add logger/listener
oe.addProcessingEventListener(listener);
// run
oe.run(); // should block until terminated
return listener.isSuccess() ? numSteps : -1;
} else
return 0;
}
开发者ID:geosolutions-it,项目名称:soil_sealing,代码行数:59,代码来源:CoverageUtilities.java
示例12: transformRequestEnvelope
import org.geotools.data.DataSourceException; //导入依赖的package包/类
/**
* transforms (if necessary) the requested envelope into the CRS used by
* this reader.
*
* @throws DataSourceException
*/
public static void transformRequestEnvelope(
final GeoWaveRasterReaderState state,
final CoordinateReferenceSystem crs )
throws DataSourceException {
if (CRS.equalsIgnoreMetadata(
state.getRequestedEnvelope().getCoordinateReferenceSystem(),
crs)) {
state.setRequestEnvelopeXformed(state.getRequestedEnvelope());
return; // and finish
}
try {
/** Buffered factory for coordinate operations. */
// transforming the envelope back to the dataset crs in
final MathTransform transform = OPERATION_FACTORY.createOperation(
state.getRequestedEnvelope().getCoordinateReferenceSystem(),
crs).getMathTransform();
if (transform.isIdentity()) { // Identity Transform ?
state.setRequestEnvelopeXformed(state.getRequestedEnvelope());
return; // and finish
}
state.setRequestEnvelopeXformed(CRS.transform(
transform,
state.getRequestedEnvelope()));
state.getRequestEnvelopeXformed().setCoordinateReferenceSystem(
crs);
// if (config.getIgnoreAxisOrder() == false) { // check for axis
// order
// required
final int indexX = indexOfX(crs);
final int indexY = indexOfY(crs);
final int indexRequestedX = indexOfX(state.getRequestedEnvelope().getCoordinateReferenceSystem());
final int indexRequestedY = indexOfY(state.getRequestedEnvelope().getCoordinateReferenceSystem());
// x Axis problem ???
if ((indexX == indexRequestedY) && (indexY == indexRequestedX)) {
state.setAxisSwap(true);
final Rectangle2D tmp = new Rectangle2D.Double(
state.getRequestEnvelopeXformed().getMinimum(
1),
state.getRequestEnvelopeXformed().getMinimum(
0),
state.getRequestEnvelopeXformed().getSpan(
1),
state.getRequestEnvelopeXformed().getSpan(
0));
state.setRequestEnvelopeXformed(new GeneralEnvelope(
tmp));
state.getRequestEnvelopeXformed().setCoordinateReferenceSystem(
crs);
}
else if ((indexX == indexRequestedX) && (indexY == indexRequestedY)) {
// everything is fine
}
else {
throw new DataSourceException(
"Unable to resolve the X Axis problem");
}
// }
}
catch (final Exception e) {
throw new DataSourceException(
"Unable to create a coverage for this source",
e);
}
}
开发者ID:locationtech,项目名称:geowave,代码行数:79,代码来源:GeoWaveRasterReader.java
示例13: lockFeatures
import org.geotools.data.DataSourceException; //导入依赖的package包/类
/**
* DOCUMENT ME!
*
* @param query DOCUMENT ME!
*
* @return DOCUMENT ME!
*
* @throws IOException DOCUMENT ME!
* @throws DataSourceException DOCUMENT ME!
*/
public int lockFeatures(Query query) throws IOException {
if (source instanceof FeatureLocking) {
return ((FeatureLocking<SimpleFeatureType, SimpleFeature>) source).lockFeatures(query);
} else {
throw new DataSourceException("FeatureTypeConfig does not supports locking");
}
}
开发者ID:STEMLab,项目名称:geoserver-3d-extension,代码行数:18,代码来源:GeoServerFeatureLocking.java
示例14: GDALGeoTiffReader
import org.geotools.data.DataSourceException; //导入依赖的package包/类
/**
* Creates a new instance of a {@link DTEDReader}. I assume nothing about
* file extension.
*
* @param input
* Source object for which we want to build an {@link DTEDReader}
* .
* @throws DataSourceException
*/
public GDALGeoTiffReader(
Object input )
throws DataSourceException {
this(
input,
null);
}
开发者ID:locationtech,项目名称:geowave,代码行数:17,代码来源:GDALGeoTiffReader.java
示例15: wkb2Geometry
import org.geotools.data.DataSourceException; //导入依赖的package包/类
/**
* This method will convert a Well Known Text representation to a
* JTS Geometry object.
*
* @param wkt the wkt string
*
* @return a JTS Geometry object that is equivalent to the WTB
* representation passed in by param wkb
*
* @throws IOException if more than one geometry object was found in the
* WTB representation, or if the parser could not parse the WKB
* representation.
*/
private Geometry wkb2Geometry(String wkt)
throws IOException {
if (wkt == null) //DJB: null value from database --> null geometry (the same behavior as WKT). NOTE: sending back a GEOMETRYCOLLECTION(EMPTY) is also a possibility, but this is not the same as NULL
return null;
try {
return wktReader.read(wkt);
} catch (Exception e) {
throw new DataSourceException("An exception occurred while parsing WKB data", e);
}
}
开发者ID:DennisPallett,项目名称:gt-jdbc-monetdb,代码行数:24,代码来源:WKTAttributeIO.java
注:本文中的org.geotools.data.DataSourceException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论