com.vividsolutions.jts.io.ParseException类的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(8.0k)|赞(0)|评价(0)|浏览(320)

本文整理了Java中com.vividsolutions.jts.io.ParseException类的一些代码示例,展示了ParseException类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ParseException类的具体详情如下:
包路径:com.vividsolutions.jts.io.ParseException
类名称:ParseException

ParseException介绍

[英]Thrown by a WKTReader when a parsing problem occurs.
[中]出现解析问题时由WKTReader抛出。

代码示例

代码示例来源:origin: com.vividsolutions/jts

private void parseErrorWithLine(String msg)
throws ParseException
{
 throw new ParseException(msg + " (line " + tokenizer.lineno() + ")");
}

代码示例来源:origin: aseldawy/spatialhadoop2

@Override
public void readFields(DataInput in) throws IOException {
 try {
  byte[] wkb = new byte[in.readInt()];
  in.readFully(wkb);
  geom = wkbReader.read(wkb);
 } catch (ParseException e) {
  e.printStackTrace();
  throw new IOException(e);
 }
}

代码示例来源:origin: org.n52.epos/epos-transform-om

@Override
public void parseValue(XmlObject value, MapEposEvent result) {
  Geometry geom;
  try {
    geom = GMLGeometryFactory.parseGeometry(value);
  } catch (ParseException e) {
    logger.warn(e.getMessage(), e);
    return;
  }
  if (geom != null) {
    result.put(MapEposEvent.GEOMETRY_KEY, geom);
  }
}

代码示例来源:origin: org.geotools/gt-imagemosaic

LOGGER.log(Level.FINE, e.getLocalizedMessage(), e);

代码示例来源:origin: org.fudaa.framework.ctulu/ctulu-gis

private Geometry readTextObject() throws IOException {
 try {
  mifText_ = mif_.getToken(' ', true, true);
 } catch (final ParseException e) {
  throw new IOException(e.getMessage());
 }
 final Coordinate c1 = readMIFCoordinate();
 final Coordinate c2 = readMIFCoordinate();
 final Coordinate p = new Coordinate((c1.x + c2.x) / 2, (c1.y + c2.y) / 2);
 return geomFactory_.createPoint(p);
}

代码示例来源:origin: deegree/deegree3

} catch ( ParseException e ) {
  LOG.info( "WKB from the DB could not be parsed: '{}'.",
       e.getLocalizedMessage() );
  LOG.info( "For PostGIS users: you have to select the geometry field 'asbinary(geometry)'." );
  LOG.trace( "Stack trace:", e );

代码示例来源:origin: org.geotools/gt-mif

private Geometry readTextObject() throws IOException {
    try {
      mifText = mif.getToken(' ', true, true);
    } catch (ParseException e) {
      throw new IOException(e.getMessage());
    }
    Coordinate c1 = readMIFCoordinate();
    Coordinate c2 = readMIFCoordinate();
    Coordinate p = new Coordinate((c1.x + c2.x) / 2, (c1.y + c2.y) / 2);
    return geomFactory.createPoint(p);
  }
}

代码示例来源:origin: com.vividsolutions/jts

/**
 * Reads a Well-Known Text representation of a {@link Geometry}
 * from a {@link Reader}.
 *
 *@param  reader           a Reader which will return a <Geometry Tagged Text>
 *      string (see the OpenGIS Simple Features Specification)
 *@return                  a <code>Geometry</code> read from <code>reader</code>
 *@throws  ParseException  if a parsing problem occurs
 */
public Geometry read(Reader reader) throws ParseException {
 tokenizer = new StreamTokenizer(reader);
 // set tokenizer to NOT parse numbers
 tokenizer.resetSyntax();
 tokenizer.wordChars('a', 'z');
 tokenizer.wordChars('A', 'Z');
 tokenizer.wordChars(128 + 32, 255);
 tokenizer.wordChars('0', '9');
 tokenizer.wordChars('-', '-');
 tokenizer.wordChars('+', '+');
 tokenizer.wordChars('.', '.');
 tokenizer.whitespaceChars(0, ' ');
 tokenizer.commentChar('#');
 try {
  return readGeometryTaggedText();
 }
 catch (IOException e) {
  throw new ParseException(e.toString());
 }
}

代码示例来源:origin: osmlab/atlas

public static Geometry createJtsGeometryFromWKT(final String wktString)
{
  Geometry geometry = null;
  try
  {
    geometry = reader.read(wktString);
  }
  catch (final ParseException e)
  {
    e.printStackTrace();
  }
  return geometry;
};

代码示例来源:origin: deegree/deegree3

return null;
} catch ( ParseException e ) {
  LOG.info( "BBox could not be read: '{}'.", e.getLocalizedMessage() );
  LOG.trace( "Stack trace:", e );
  available = false;

代码示例来源:origin: org.n52.epos/epos-pattern-util

private static Geometry extractGeometry(Object g0) {
  if (g0 instanceof Geometry) {
    //geometry given -> cast
    return (Geometry) g0;
  }
  else {
    //parse string
    WKTReader r = new WKTReader();
    try {
      return r.read(g0.toString());
    }
    catch (ParseException e) {
      logger.warn(e.getMessage(), e);
    }
  }
  return null;
}

代码示例来源:origin: com.vividsolutions/jts

private MultiLineString readMultiLineString() throws IOException, ParseException
{
 int numGeom = dis.readInt();
 LineString[] geoms = new LineString[numGeom];
 for (int i = 0; i < numGeom; i++) {
  Geometry g = readGeometry();
  if (! (g instanceof LineString))
   throw new ParseException(INVALID_GEOM_TYPE_MSG + "MultiLineString");
  geoms[i] = (LineString) g;
 }
 return factory.createMultiLineString(geoms);
}

代码示例来源:origin: FutureCitiesCatapult/TomboloDigitalConnector

public Geometry getShape(String wtk) throws FactoryException, TransformException {
  GeometryFactory geometryFactory = new GeometryFactory(new PrecisionModel(), Subject.SRID);
  WKTReader reader = new WKTReader(geometryFactory);
  MathTransform crsTransform = GeotoolsDataStoreUtils.makeCrsTransform("EPSG:27700");
  try {
    LineString line = (LineString) reader.read(wtk);
    Geometry transformedGeom = JTS.transform(line, crsTransform);
    return transformedGeom;
  } catch (ParseException e) {
    e.printStackTrace();
    log.error("Not a valid geometry");
    return null;
  }
}

代码示例来源:origin: deegree/deegree3

@Override
  public <T> TypedObjectNode[] evaluate( T obj, XPathEvaluator<T> xpathEvaluator )
              throws FilterEvaluationException {
    TypedObjectNode[] crs = getParams()[0].evaluate( obj, xpathEvaluator );
    TypedObjectNode[] geom = getParams()[1].evaluate( obj, xpathEvaluator );
    if ( crs.length != 1 ) {
      throw new FilterEvaluationException( "The GeometryFromWKT function's first argument must "
                         + "evaluate to exactly one value." );
    }
    if ( geom.length != 1 ) {
      throw new FilterEvaluationException( "The GeometryFromWKT function's second argument must "
                         + "evaluate to exactly one value." );
    }
    ICRS srs = CRSManager.getCRSRef( crs[0].toString() );
    String wkt = geom[0].toString();
    WKTReader reader = new WKTReader( srs );
    try {
      return new TypedObjectNode[] { reader.read( wkt ) };
    } catch ( ParseException e ) {
      LOG.trace( "Stack trace:", e );
      throw new FilterEvaluationException( "GeometryFromWKT error while parsing WKT: "
                         + e.getLocalizedMessage() );
    }
  }
};

代码示例来源:origin: org.n52.wps/52n-wps-io-impl

@Override
public JTSGeometryBinding parse(InputStream input, String mimeType, String schema) {
  
  try {
    Geometry g = new WKTReader().read(new InputStreamReader(input));	
    
    return new JTSGeometryBinding(g);
    
  } catch (ParseException e) {
    LOGGER.error(e.getMessage(), e);
  }finally{
    try {
      input.close();
    } catch (IOException e) {
      LOGGER.error(e.getMessage(), e);
    }
  }
  
  return null;
}

代码示例来源:origin: com.vividsolutions/jts

private MultiPolygon readMultiPolygon() throws IOException, ParseException
{
 int numGeom = dis.readInt();
 Polygon[] geoms = new Polygon[numGeom];
 for (int i = 0; i < numGeom; i++) {
  Geometry g = readGeometry();
  if (! (g instanceof Polygon))
   throw new ParseException(INVALID_GEOM_TYPE_MSG + "MultiPolygon");
  geoms[i] = (Polygon) g;
 }
 return factory.createMultiPolygon(geoms);
}

代码示例来源:origin: bcdev/beam

@Override
public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
  if (placemark != null) {
    final AttributeDescriptor attributeDescriptor
        = placemark.getFeature().getFeatureType().getAttributeDescriptors().get(rowIndex);
    final Class<?> binding = attributeDescriptor.getType().getBinding();
    if (String.class.isAssignableFrom(binding)) {
      placemark.setAttributeValue(attributeDescriptor.getLocalName(), aValue);
    } else if (Geometry.class.isAssignableFrom(binding)) {
      WKTReader reader = new WKTReader();
      try {
        final Geometry geometry = reader.read((String) aValue);
        placemark.setAttributeValue(attributeDescriptor.getLocalName(), geometry);
      } catch (ParseException e) {
        // No way to handle this any further   :(
        e.printStackTrace();
      }
    }
  }
}

代码示例来源:origin: org.fudaa.framework.ctulu/ctulu-gis

throw new IOException(_evt.getMessage());

代码示例来源:origin: com.vividsolutions/jts

private MultiPoint readMultiPoint() throws IOException, ParseException
{
 int numGeom = dis.readInt();
 Point[] geoms = new Point[numGeom];
 for (int i = 0; i < numGeom; i++) {
  Geometry g = readGeometry();
  if (! (g instanceof Point))
   throw new ParseException(INVALID_GEOM_TYPE_MSG + "MultiPoint");
  geoms[i] = (Point) g;
 }
 return factory.createMultiPoint(geoms);
}

代码示例来源:origin: org.fudaa.framework.ctulu/ctulu-gis

public FeatureCollection open(final InputStream _in) throws IOException{
 if (gmlInput_ == null) {
  return null;
 }
 try {
  final InputStreamReader inputStreamReader = new InputStreamReader(_in, CtuluLibFile.getUTF8Charset());
  return read(new BufferedReader(inputStreamReader), "inputStream");
 } catch (final ParseException _evt) {
  FuLog.error(_evt);
  throw new IOException(_evt.getMessage());
 } catch (final SchemaException _evt) {
  FuLog.error(_evt);
  throw new IOException(_evt.getMessage());
 } finally {}
}

相关文章