当前位置: 首页>>代码示例>>Java>>正文


Java ParseException类代码示例

本文整理汇总了Java中com.vividsolutions.jts.io.ParseException的典型用法代码示例。如果您正苦于以下问题:Java ParseException类的具体用法?Java ParseException怎么用?Java ParseException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ParseException类属于com.vividsolutions.jts.io包,在下文中一共展示了ParseException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createPolygon

import com.vividsolutions.jts.io.ParseException; //导入依赖的package包/类
/**
 *
 * @param xs
 * @return
 * @throws ParseException
 */
public static Polygon createPolygon(double[]...xs) throws ParseException{
	StringBuilder builder =new StringBuilder("POLYGON((");

	for(int i=0;i<xs.length;i++){
		double x[]=xs[i];
		if(i<(xs.length-1))
			builder=builder.append(x[0]).append(" ").append(x[1]).append(",");
		else
			builder=builder.append(x[0]).append(" ").append(x[1]).append("))");
	}
	Polygon imageP = (Polygon) new WKTReader().read(builder.toString());
	/*Coordinate[]cs=new Coordinate[xs.length];
	for(int i=0;i<xs.length;i++){
		cs[i]=new Coordinate(xs[i][0],xs[i][1]);
	}
	GeometryFactory factor=new GeometryFactory();
	Polygon imageP=factor.createPolygon(cs);*/

	return imageP;
}
 
开发者ID:ec-europa,项目名称:sumo,代码行数:27,代码来源:PolygonOp.java

示例2: getFrame

import com.vividsolutions.jts.io.ParseException; //导入依赖的package包/类
public static Geometry getFrame(GeoImageReader gir) throws GeoTransformException{
    try {
        GeoTransform gt = gir.getGeoTransform();
        double[] x0;
        double[] x1;
        double[] x2;
        double[] x3;
        x0 = gt.getGeoFromPixel(-50, -50);
        x2 = gt.getGeoFromPixel(50 + gir.getWidth(), 50 + gir.getHeight());
        x3 = gt.getGeoFromPixel(50 + gir.getWidth(), -50);
        x1 = gt.getGeoFromPixel(-50, 50 + gir.getHeight());
        return new WKTReader().read("POLYGON((" + x0[0] + " " + x0[1] + "," + x1[0] + " " + x1[1] + "," + x2[0] + " " + x2[1] + "," + x3[0] + " " + x3[1] + "," + x0[0] + " " + x0[1] + "" + "))");
    } catch (ParseException ex) {
    	logger.error(ex.getMessage(),ex);
    }
    return null;
}
 
开发者ID:ec-europa,项目名称:sumo,代码行数:18,代码来源:GeometryExtractor.java

示例3: postFilter

import com.vividsolutions.jts.io.ParseException; //导入依赖的package包/类
/** A post filter on Products, returns false is the product must not be saved. */
private boolean postFilter(Product product)
{
   if (validator != null)
   {
      String jts_footprint = getJTSFootprint(product);
      if (jts_footprint == null || jts_footprint.isEmpty())
      {
         return false;
      }
      try
      {
         if (!validator.validate(jts_footprint))
         {
            return false;
         }
      }
      catch (ParseException ex)
      {
         return false;
      }
   }
   return true;
}
 
开发者ID:SentinelDataHub,项目名称:dhus-core,代码行数:25,代码来源:ODataProductSynchronizer.java

示例4: loadSplicedGeometries

import com.vividsolutions.jts.io.ParseException; //导入依赖的package包/类
@Override
@Transactional(readOnly = true)
public List<Geometry> loadSplicedGeometries(final Collection<Long> zoneIds) {
    if (zoneIds.isEmpty()) {
        return emptyList();
    }

    final GeometryFactory geometryFactory = GISUtils.getGeometryFactory(GISUtils.SRID.ETRS_TM35FIN);
    final WKBReader wkbReader = new WKBReader(geometryFactory);
    final MapSqlParameterSource params = new MapSqlParameterSource()
            .addValue("chunkSize", 2048)
            .addValue("zoneIds", zoneIds);

    return namedParameterJdbcTemplate.query(
            "SELECT ST_AsBinary(ST_SubDivide(geom, :chunkSize)) AS geom FROM zone WHERE zone_id IN (:zoneIds)",
            params, (resultSet, i) -> {
                final byte[] wkb = resultSet.getBytes("geom");

                try {
                    return wkbReader.read(wkb);
                } catch (ParseException e) {
                    throw new RuntimeException(e);
                }
            });
}
 
开发者ID:suomenriistakeskus,项目名称:oma-riista-web,代码行数:26,代码来源:GISZoneRepositoryImpl.java

示例5: getCoordinates

import com.vividsolutions.jts.io.ParseException; //导入依赖的package包/类
/**
 * Returns the next array of <code>Coordinate</code>s in the stream.
 * 
 * @param tokenizer tokenizer over a stream of text in Well-known Text
 *        format. The next element returned by the stream should be L_PAREN
 *        (the beginning of "(x1 y1, x2 y2, ..., xn yn)") or EMPTY.
 * @return the next array of <code>Coordinate</code>s in the stream, or an
 *         empty array if EMPTY is the next element returned by the stream.
 * @throws IOException if an I/O error occurs
 * @throws ParseException if an unexpected token was encountered
 */
private MCoordinate[] getCoordinates() throws IOException, ParseException {
    String nextToken = getNextEmptyOrOpener();
    if (nextToken.equals(EMPTY)) {
        return new MCoordinate[] {};
    }
    ArrayList coordinates = new ArrayList();
    coordinates.add(getPreciseCoordinate());
    nextToken = getNextCloserOrComma();
    while (nextToken.equals(COMMA)) {
        coordinates.add(getPreciseCoordinate());
        nextToken = getNextCloserOrComma();
    }
    return (MCoordinate[]) coordinates.toArray(new MCoordinate[coordinates
            .size()]);
}
 
开发者ID:gvSIGAssociation,项目名称:gvnix1,代码行数:27,代码来源:EWKTReader.java

示例6: getNextNumber

import com.vividsolutions.jts.io.ParseException; //导入依赖的package包/类
/**
 * Parses the next number in the stream. Numbers with exponents are handled.
 * 
 * @param tokenizer tokenizer over a stream of text in Well-known Text
 *        format. The next token must be a number.
 * @return the next number in the stream
 * @throws ParseException if the next token is not a valid number
 * @throws IOException if an I/O error occurs
 */
private double getNextNumber() throws IOException, ParseException {
    int type = tokenizer.nextToken();
    switch (type) {
    case StreamTokenizer.TT_WORD: {
        try {
            return Double.parseDouble(tokenizer.sval);
        }
        catch (NumberFormatException ex) {
            throw new ParseException("Invalid number: " + tokenizer.sval);
        }
    }
    }
    parseError("number");
    return 0.0;
}
 
开发者ID:gvSIGAssociation,项目名称:gvnix1,代码行数:25,代码来源:EWKTReader.java

示例7: getNextWord

import com.vividsolutions.jts.io.ParseException; //导入依赖的package包/类
/**
 * Returns the next word in the stream.
 * 
 * @param tokenizer tokenizer over a stream of text in Well-known Text
 *        format. The next token must be a word.
 * @return the next word in the stream as uppercase text
 * @throws ParseException if the next token is not a word
 * @throws IOException if an I/O error occurs
 */
private String getNextWord() throws IOException, ParseException {
    int type = tokenizer.nextToken();
    switch (type) {
    case StreamTokenizer.TT_WORD:

        String word = tokenizer.sval;
        if (word.equalsIgnoreCase(EMPTY))
            return EMPTY;
        return word;

    case '(':
        return L_PAREN;
    case ')':
        return R_PAREN;
    case ',':
        return COMMA;
    case '=':
        return EQUALS;
    case ';':
        return SEMICOLON;
    }
    parseError("word");
    return null;
}
 
开发者ID:gvSIGAssociation,项目名称:gvnix1,代码行数:34,代码来源:EWKTReader.java

示例8: readPolygonText

import com.vividsolutions.jts.io.ParseException; //导入依赖的package包/类
/**
 * Creates a <code>Polygon</code> using the next token in the stream.
 * 
 * @param hasM
 * @param tokenizer tokenizer over a stream of text in Well-known Text
 *        format. The next tokens must form a &lt;Polygon Text&gt;.
 * @return a <code>Polygon</code> specified by the next token in the stream
 * @throws ParseException if the coordinates used to create the
 *         <code>Polygon</code> shell and holes do not form closed
 *         linestrings, or if an unexpected token was encountered.
 * @throws IOException if an I/O error occurs
 */
private Polygon readPolygonText() throws IOException, ParseException {

    // PolygonM is not supported
    setHasM(false);

    String nextToken = getNextEmptyOrOpener();
    if (nextToken.equals(EMPTY)) {
        return geometryFactory.createPolygon(
                geometryFactory.createLinearRing(new Coordinate[] {}),
                new LinearRing[] {});
    }
    ArrayList holes = new ArrayList();
    LinearRing shell = readLinearRingText();
    nextToken = getNextCloserOrComma();
    while (nextToken.equals(COMMA)) {
        LinearRing hole = readLinearRingText();
        holes.add(hole);
        nextToken = getNextCloserOrComma();
    }
    LinearRing[] array = new LinearRing[holes.size()];
    return geometryFactory.createPolygon(shell,
            (LinearRing[]) holes.toArray(array));
}
 
开发者ID:gvSIGAssociation,项目名称:gvnix1,代码行数:36,代码来源:EWKTReader.java

示例9: readMultiPolygonText

import com.vividsolutions.jts.io.ParseException; //导入依赖的package包/类
/**
 * Creates a <code>MultiPolygon</code> using the next token in the stream.
 * 
 * @param hasM
 * @param tokenizer tokenizer over a stream of text in Well-known Text
 *        format. The next tokens must form a &lt;MultiPolygon Text&gt;.
 * @return a <code>MultiPolygon</code> specified by the next token in the
 *         stream, or if if the coordinates used to create the
 *         <code>Polygon</code> shells and holes do not form closed
 *         linestrings.
 * @throws IOException if an I/O error occurs
 * @throws ParseException if an unexpected token was encountered
 */
private MultiPolygon readMultiPolygonText() throws IOException,
        ParseException {

    // MultiPolygonM is not supported
    setHasM(false);

    String nextToken = getNextEmptyOrOpener();
    if (nextToken.equals(EMPTY)) {
        return geometryFactory.createMultiPolygon(new Polygon[] {});
    }
    ArrayList polygons = new ArrayList();
    Polygon polygon = readPolygonText();
    polygons.add(polygon);
    nextToken = getNextCloserOrComma();
    while (nextToken.equals(COMMA)) {
        polygon = readPolygonText();
        polygons.add(polygon);
        nextToken = getNextCloserOrComma();
    }
    Polygon[] array = new Polygon[polygons.size()];
    return geometryFactory.createMultiPolygon((Polygon[]) polygons
            .toArray(array));
}
 
开发者ID:gvSIGAssociation,项目名称:gvnix1,代码行数:37,代码来源:EWKTReader.java

示例10: readGeometryCollectionText

import com.vividsolutions.jts.io.ParseException; //导入依赖的package包/类
/**
 * Creates a <code>GeometryCollection</code> using the next token in the
 * stream.
 * 
 * @param tokenizer tokenizer over a stream of text in Well-known Text
 *        format. The next tokens must form a &lt;GeometryCollection
 *        Text&gt;.
 * @return a <code>GeometryCollection</code> specified by the next token in
 *         the stream
 * @throws ParseException if the coordinates used to create a
 *         <code>Polygon</code> shell and holes do not form closed
 *         linestrings, or if an unexpected token was encountered
 * @throws IOException if an I/O error occurs
 */
private GeometryCollection readGeometryCollectionText() throws IOException,
        ParseException {

    String nextToken = getNextEmptyOrOpener();
    if (nextToken.equals(EMPTY)) {
        return geometryFactory.createGeometryCollection(new Geometry[] {});
    }
    ArrayList geometries = new ArrayList();
    Geometry geometry = readGeometryTaggedText();
    geometries.add(geometry);
    nextToken = getNextCloserOrComma();
    while (nextToken.equals(COMMA)) {
        geometry = readGeometryTaggedText();
        geometries.add(geometry);
        nextToken = getNextCloserOrComma();
    }
    Geometry[] array = new Geometry[geometries.size()];
    return geometryFactory.createGeometryCollection((Geometry[]) geometries
            .toArray(array));
}
 
开发者ID:gvSIGAssociation,项目名称:gvnix1,代码行数:35,代码来源:EWKTReader.java

示例11: parseGeometry

import com.vividsolutions.jts.io.ParseException; //导入依赖的package包/类
private void parseGeometry(BuildingImport building) throws ParseException {
	String geom = building.getGeometryRawString();
	StringBuilder wktForPolygon = new StringBuilder("POLYGON((");
	geom = geom.replace("[", "").replace("]", "").replace(",", "");
	String[] coords = geom.split(" ");
	for (int i = 0; i < coords.length; i++) {
		if (i % 2 == 1) {
			String coordinates = coords[i - 1] + " " + coords[i];
			wktForPolygon.append(coordinates);
			if (i < coords.length - 1) {
				wktForPolygon.append(", ");
			}
			// Add a new point with string coordinates
			Coordinates sc = new Coordinates(coords[i - 1], coords[i], "0.0");
			building.getCoordinates().add(sc);
			// Add a new point with real geometry
			Point point = (Point) this.wktReader.read("POINT(" + coordinates + ")");
			building.getPoints().add(point);
		}
	}
	wktForPolygon.append("))");
	building.setGeometryAsWKT(wktForPolygon.toString());
	// building.setPolygon((Polygon) wktReader.read(wktForPolygon.toString()));
}
 
开发者ID:vince-from-nice,项目名称:osmaxil,代码行数:25,代码来源:ParisBuildingImportParser.java

示例12: serialize

import com.vividsolutions.jts.io.ParseException; //导入依赖的package包/类
@Override
public DBObject serialize(final RyaStatement ryaStatement) {
    final BasicDBObjectBuilder builder = BasicDBObjectBuilder.start("_id", ryaStatement.getSubject().hashCode());
    final URI obj = ryaStatement.getObject().getDataType();


    if(obj.equals(GeoConstants.GEO_AS_WKT) || obj.equals(GeoConstants.GEO_AS_GML) ||
       obj.equals(GeoConstants.XMLSCHEMA_OGC_GML) || obj.equals(GeoConstants.XMLSCHEMA_OGC_WKT)) {
        try {
            final Statement statement = RyaToRdfConversions.convertStatement(ryaStatement);
            final Geometry geo = GeoParseUtils.getGeometry(statement, new GmlParser());
            if (geo.getNumPoints() > 1) {
                builder.add(GEO_KEY, geoStrategy.getCorrespondingPoints(geo));
            } else {
                builder.add(GEO_KEY, geoStrategy.getDBPoint(geo));
            }
        } catch (final ParseException e) {
            LOG.error("Could not create geometry for statement " + ryaStatement, e);
            return null;
        }
    } else {
        builder.add(TIME_KEY, temporalStrategy.getTimeValue(ryaStatement.getObject().getData()));
    }
    return builder.get();
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:26,代码来源:GeoTemporalMongoDBStorageStrategy.java

示例13: getGeoObjs

import com.vividsolutions.jts.io.ParseException; //导入依赖的package包/类
private DBObject[] getGeoObjs(final Collection<IndexingExpr> geoFilters) {
    final List<DBObject> objs = new ArrayList<>();
    geoFilters.forEach(filter -> {
        final GeoPolicy policy = GeoPolicy.fromURI(filter.getFunction());
        final WKTReader reader = new WKTReader();
        final String geoStr = ((Value) filter.getArguments()[0]).stringValue();
        try {
            //This method is what is used in the GeoIndexer.
            final Geometry geo = reader.read(geoStr);
            objs.add(getGeoObject(geo, policy));
        } catch (final GeoTemporalIndexException | UnsupportedOperationException | ParseException e) {
            LOG.error("Unable to parse '" + geoStr + "'.", e);
        }
    });
    return objs.toArray(new DBObject[]{});
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:17,代码来源:GeoTemporalMongoDBStorageStrategy.java

示例14: serialize

import com.vividsolutions.jts.io.ParseException; //导入依赖的package包/类
@Override
public DBObject serialize(final RyaStatement ryaStatement) {
    // if the object is wkt, then try to index it
    // write the statement data to the fields
    try {
        final Statement statement = RyaToRdfConversions.convertStatement(ryaStatement);
        final Geometry geo = (new WKTReader()).read(GeoParseUtils.getWellKnownText(statement));
        if(geo == null) {
            LOG.error("Failed to parse geo statement: " + statement.toString());
            return null;
        }
        final BasicDBObject base = (BasicDBObject) super.serialize(ryaStatement);
        if (geo.getNumPoints() > 1) {
            base.append(GEO, getCorrespondingPoints(geo));
        } else {
            base.append(GEO, getDBPoint(geo));
        }
        return base;
    } catch(final ParseException e) {
        LOG.error("Could not create geometry for statement " + ryaStatement, e);
        return null;
    }
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:24,代码来源:GeoMongoDBStorageStrategy.java

示例15: getGeometry

import com.vividsolutions.jts.io.ParseException; //导入依赖的package包/类
/**
 * Parse GML/wkt literal to Geometry
 *
 * @param statement
 * @return
 * @throws ParseException
 * @throws ParserConfigurationException
 * @throws SAXException
 * @throws IOException
 */
public static Geometry getGeometry(final Statement statement, GmlToGeometryParser gmlToGeometryParser) throws ParseException {
    // handle GML or WKT
    final Literal lit = getLiteral(statement);
    if (GeoConstants.XMLSCHEMA_OGC_WKT.equals(lit.getDatatype())) {
        final String wkt = lit.getLabel().toString();
        return (new WKTReader()).read(wkt);
    } else if (GeoConstants.XMLSCHEMA_OGC_GML.equals(lit.getDatatype())) {
        final String gml = lit.getLabel().toString();
        try {
            return getGeometryGml(gml, gmlToGeometryParser);
        } catch (IOException | SAXException | ParserConfigurationException e) {
            throw new ParseException(e);
        }
    } else {
        throw new ParseException("Literal is unknown geo type, expecting WKT or GML: " + statement.toString());
    }
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:28,代码来源:GeoParseUtils.java


注:本文中的com.vividsolutions.jts.io.ParseException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。