org.opengis.referencing.FactoryException Java Examples

The following examples show how to use org.opengis.referencing.FactoryException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CustomCrsPanel.java    From snap-desktop with GNU General Public License v3.0 6 votes vote down vote up
public static Set<GeodeticDatum> createDatumSet() {
    DatumAuthorityFactory factory = ReferencingFactoryFinder.getDatumAuthorityFactory("EPSG", null);
    List<String> datumCodes = retrieveCodes(GeodeticDatum.class, factory);
    Set<GeodeticDatum> datumSet = new TreeSet<>(AbstractIdentifiedObject.NAME_COMPARATOR);
    for (String datumCode : datumCodes) {
        try {
            DefaultGeodeticDatum geodeticDatum = (DefaultGeodeticDatum) factory.createGeodeticDatum(datumCode);
            if (geodeticDatum.getBursaWolfParameters().length != 0 ||
                    DefaultGeodeticDatum.isWGS84(geodeticDatum)) {
                datumSet.add(geodeticDatum);
            }
        } catch (FactoryException ignored) {
        }
    }
    return datumSet;
}
 
Example #2
Source File: TestProducts.java    From snap-desktop with GNU General Public License v3.0 6 votes vote down vote up
public static Product createProduct5() {
    try {
        Product product = new Product("Test_Product_5_CRS", "Test_Type_5_CRS", 512, 512);
        product.getMetadataRoot().addElement(new MetadataElement("Global_Attributes"));
        product.getMetadataRoot().addElement(new MetadataElement("Local_Attributes"));
        product.setModified(false);
        product.addBand("Band_A", "sin(4 * PI * sqrt( sq(X/1000.0 - 1) + sq(Y/500.0 - 1) ))");
        product.setSceneGeoCoding(new CrsGeoCoding(DefaultGeographicCRS.WGS84, 512, 512, 0, 10, 1, 1));

        final String b_expression = "sin(4 * PI * sqrt( 2.0 * abs(X/1000.0 * Y/500.0) ))";
        final VirtualBand band_b = new VirtualBand("Band_B", ProductData.TYPE_FLOAT32, 1024, 256, b_expression);
        band_b.setGeoCoding(new CrsGeoCoding(DefaultGeographicCRS.WGS84, 1024, 256, 0, 10, 0.5, 2.0));
        band_b.setNoDataValueUsed(true);
        product.addBand(band_b);

        return product;
    } catch (FactoryException | TransformException e) {
        return null;
    }
}
 
Example #3
Source File: ArcGISSoeMetadataHandler.java    From SensorWebClient with GNU General Public License v2.0 6 votes vote down vote up
public Point getPointOfSamplingFeatureType(SFSamplingFeatureType sfSamplingFeature, CRSUtils referenceHelper) throws XmlException, FactoryException {
	XmlCursor cursor = sfSamplingFeature.newCursor();
	if (cursor.toChild(new QName("http://www.opengis.net/samplingSpatial/2.0", "shape"))) {
		ShapeDocument shapeDoc = ShapeDocument.Factory.parse(cursor.getDomNode());
		AbstractGeometryType abstractGeometry = shapeDoc.getShape().getAbstractGeometry();
		if (abstractGeometry instanceof PointTypeImpl) {
			PointTypeImpl pointDoc = (PointTypeImpl) abstractGeometry;
			DirectPositionType pos = pointDoc.getPos();
			String[] lonLat = pos.getStringValue().split(" ");
               Double x = Double.parseDouble(lonLat[0]);
               Double y = Double.parseDouble(lonLat[1]);
	        return referenceHelper.createPoint(x, y, "CRS:84");
		}
	}
	return null;
}
 
Example #4
Source File: FunctionAsWKT.java    From GeoTriples with Apache License 2.0 6 votes vote down vote up
@Override
public Object execute(Object argument, QLTerm qlterm)
		throws SAXException, IOException, ParserConfigurationException, FactoryException,
		MalformedGeometryException, ParseException {
	if (qlterm.equals(QLTerm.ROW_CLASS)){
		Object geom = argument;
		if (geom instanceof  String) {
			return "<http://www.opengis.net/def/crs/EPSG/0/" + Config.EPSG_CODE + "> " + geom;
		}
		else if (geom instanceof  Geometry){
			WKTWriter wkt = new WKTWriter();
			return "<http://www.opengis.net/def/crs/EPSG/0/" + Config.EPSG_CODE + "> " +  (wkt.write((Geometry) geom));
		}
	}
	else if (qlterm.equals(QLTerm.SHP_CLASS) && argument instanceof org.gdal.ogr.Geometry) {
		org.gdal.ogr.Geometry gdalgeom=(org.gdal.ogr.Geometry )argument;

		return "<http://www.opengis.net/def/crs/EPSG/0/" + Config.EPSG_CODE + "> " + gdalgeom.ExportToWkt();
	}

	Geometry geometry = computeGeometry(argument, qlterm);
	return GTransormationFunctions.asWKT((Geometry) geometry, CRS.decode("EPSG:" + Config.EPSG_CODE));
}
 
Example #5
Source File: ExtractGeometryFilterVisitor.java    From geowave with Apache License 2.0 6 votes vote down vote up
/**
 * Produce an ReferencedEnvelope from the provided data parameter.
 *
 * @param data
 * @return ReferencedEnvelope
 */
private Geometry bbox(final Object data) {
  try {
    if (data == null) {
      return null;
    } else if (data instanceof Geometry) {
      return (Geometry) data;
    } else if (data instanceof ReferencedEnvelope) {
      return new GeometryFactory().toGeometry(((ReferencedEnvelope) data).transform(crs, true));

    } else if (data instanceof Envelope) {
      return new GeometryFactory().toGeometry((Envelope) data);
    } else if (data instanceof CoordinateReferenceSystem) {
      return new GeometryFactory().toGeometry(
          new ReferencedEnvelope((CoordinateReferenceSystem) data).transform(crs, true));
    }
  } catch (TransformException | FactoryException e) {
    LOGGER.warn("Unable to transform geometry", e);
    return null;
  }
  throw new ClassCastException("Could not cast data to ReferencedEnvelope");
}
 
Example #6
Source File: FunctionTouches.java    From GeoTriples with Apache License 2.0 6 votes vote down vote up
@Override
public List<? extends Object> execute(List<? extends Object> arguments, List<? extends QLTerm> qlterms)
		throws SAXException, IOException, ParserConfigurationException, FactoryException,
		MalformedGeometryException, ParseException {
	List<String> valueList = new ArrayList<>();
	log.debug("Executing FunctionTouches...");

	Geometry geometry1 = computeGeometry(arguments.get(0), qlterms.get(0));
	Geometry geometry2 = computeGeometry(arguments.get(1), qlterms.get(1));
	if (log.isTraceEnabled()) {
		log.trace("FunctionTouches: geometry0: " + geometry1);
		log.trace("FunctionTouches: geometry0: " + geometry2);
	}
	String result = GTransormationFunctions.touches(geometry1, geometry2);
	log.trace("FunctionTouches: Result: " + result);
	valueList.add(result);
	return valueList;
}
 
Example #7
Source File: RasterUtils.java    From geowave with Apache License 2.0 6 votes vote down vote up
public static ReferencedEnvelope getReferenceEnvelope(
    final GridCoverage gridCoverage,
    final CoordinateReferenceSystem targetCrs) {
  final CoordinateReferenceSystem sourceCrs = gridCoverage.getCoordinateReferenceSystem();
  final Envelope sampleEnvelope = gridCoverage.getEnvelope();

  final ReferencedEnvelope sampleReferencedEnvelope =
      new ReferencedEnvelope(
          new org.locationtech.jts.geom.Envelope(
              sampleEnvelope.getMinimum(0),
              sampleEnvelope.getMaximum(0),
              sampleEnvelope.getMinimum(1),
              sampleEnvelope.getMaximum(1)),
          gridCoverage.getCoordinateReferenceSystem());

  ReferencedEnvelope projectedReferenceEnvelope = sampleReferencedEnvelope;
  if ((targetCrs != null) && !targetCrs.equals(sourceCrs)) {
    try {
      projectedReferenceEnvelope = sampleReferencedEnvelope.transform(targetCrs, true);
    } catch (TransformException | FactoryException e) {
      LOGGER.warn("Unable to transform envelope of grid coverage to " + targetCrs.getName(), e);
    }
  }
  return projectedReferenceEnvelope;
}
 
Example #8
Source File: FunctionSubtract.java    From GeoTriples with Apache License 2.0 6 votes vote down vote up
@Override
public List<? extends Object> execute(List<? extends Object> arguments, List<? extends QLTerm> qlterms)
		throws SAXException, IOException, ParserConfigurationException, FactoryException,
		MalformedGeometryException {
	List<String> valueList = new ArrayList<>();
	log.debug("Executing FunctionSubtract...");

	if (log.isTraceEnabled()) {
		log.trace("FunctionSubtract: value0: " + arguments.get(0));
		log.trace("FunctionSubtract: value1: " + arguments.get(1));
	}
	String result = String
			.valueOf(Double.valueOf(arguments.get(0).toString()) - Double.valueOf(arguments.get(1).toString()));
	valueList.add(result);
	log.trace("FunctionSubtract: Result: " + result);

	return valueList;
}
 
Example #9
Source File: WmsAssistantPage2.java    From snap-desktop with GNU General Public License v3.0 6 votes vote down vote up
@SuppressWarnings({"unchecked"})
private String getMatchingCRSCode(Layer layer) {
    Set<String> srsSet = layer.getSrs();
    String modelSRS = CRS.toSRS(modelCRS);
    if (modelSRS != null) {
        for (String srs : srsSet) {
            try {
                final CoordinateReferenceSystem crs = CRS.decode(srs,true);
                if (CRS.equalsIgnoreMetadata(crs, modelCRS)) {
                    return srs;
                }
            } catch (FactoryException ignore) {
            }
        }
    }
    return null;
}
 
Example #10
Source File: SceneFeatureIterator.java    From geowave with Apache License 2.0 6 votes vote down vote up
public SceneFeatureIterator(
    final String providerName,
    final String collection,
    final String platform,
    final String location,
    final Date startDate,
    final Date endDate,
    final int orbitNumber,
    final int relativeOrbitNumber,
    final Filter cqlFilter,
    final String workspaceDir) throws NoSuchAuthorityCodeException, FactoryException,
    MalformedURLException, IOException, GeneralSecurityException {
  init(
      new File(workspaceDir, SCENES_DIR),
      providerName,
      collection,
      platform,
      location,
      startDate,
      endDate,
      orbitNumber,
      relativeOrbitNumber,
      cqlFilter);
}
 
Example #11
Source File: ProjectionFactory.java    From gama with GNU General Public License v3.0 6 votes vote down vote up
public IProjection forSavingWith(final IScope scope, final String code, final boolean lonFirst)
		throws FactoryException {
	CoordinateReferenceSystem crs = null;
	try {
		crs = getCRS(scope, code, lonFirst);
	} catch (final Exception e) {
		crs = null;
	}
	if (crs == null) {
		crs = getSaveCRS(scope);
	}
	final Projection gis = new Projection(world, this);
	gis.initialCRS = crs;
	// gis.computeProjection();
	gis.createTransformation(gis.computeProjection(scope));

	return gis;
}
 
Example #12
Source File: PolygonAreaCalculator.java    From geowave with Apache License 2.0 6 votes vote down vote up
private CoordinateReferenceSystem lookupUtmCrs(final double centerLat, final double centerLon)
    throws NoSuchAuthorityCodeException, FactoryException {
  final int epsgCode =
      (32700 - (Math.round((45f + (float) centerLat) / 90f) * 100))
          + Math.round((183f + (float) centerLon) / 6f);

  final String crsId = "EPSG:" + Integer.toString(epsgCode);

  CoordinateReferenceSystem crs = crsMap.get(crsId);

  if (crs == null) {
    crs = CRS.decode(crsId, true);

    crsMap.put(crsId, crs);
  }

  return crs;
}
 
Example #13
Source File: ImageGenerator.java    From hortonmachine with GNU General Public License v3.0 6 votes vote down vote up
private void expandToIncludeEnvelope( ReferencedEnvelope maxExtent, org.opengis.geometry.Envelope envelope ) {
    ReferencedEnvelope tmpExtent = new ReferencedEnvelope(envelope.getCoordinateReferenceSystem());
    DirectPosition ll = envelope.getLowerCorner();
    double[] coordinate = ll.getCoordinate();
    tmpExtent.expandToInclude(new Coordinate(coordinate[0], coordinate[1]));
    DirectPosition ur = envelope.getUpperCorner();
    coordinate = ur.getCoordinate();
    tmpExtent.expandToInclude(new Coordinate(coordinate[0], coordinate[1]));

    try {
        ReferencedEnvelope transformed = tmpExtent.transform(maxExtent.getCoordinateReferenceSystem(), true);
        maxExtent.expandToInclude(transformed);
    } catch (TransformException | FactoryException e) {
        e.printStackTrace();
    }
}
 
Example #14
Source File: OperationMethodCrsProvider.java    From snap-desktop with GNU General Public License v3.0 6 votes vote down vote up
@Override
public CoordinateReferenceSystem getCRS(final GeoPos referencePos, ParameterValueGroup parameters,
                                        GeodeticDatum datum) throws FactoryException {
    final CRSFactory crsFactory = ReferencingFactoryFinder.getCRSFactory(null);
    // in some cases, depending on the parameters set, the effective transformation can be different
    // from the transformation given by the OperationMethod.
    // So we create a new one
    final MathTransformFactory mtFactory = ReferencingFactoryFinder.getMathTransformFactory(null);
    final MathTransform transform = mtFactory.createParameterizedTransform(parameters);
    final DefaultOperationMethod operationMethod = new DefaultOperationMethod(transform);

    final Conversion conversion = new DefiningConversion(AbstractIdentifiedObject.getProperties(operationMethod),
                                                         operationMethod, transform);

    final HashMap<String, Object> baseCrsProperties = new HashMap<String, Object>();
    baseCrsProperties.put("name", datum.getName().getCode());
    GeographicCRS baseCrs = crsFactory.createGeographicCRS(baseCrsProperties,
                                                           datum,
                                                           DefaultEllipsoidalCS.GEODETIC_2D);

    final HashMap<String, Object> projProperties = new HashMap<String, Object>();
    projProperties.put("name", conversion.getName().getCode() + " / " + datum.getName().getCode());
    return crsFactory.createProjectedCRS(projProperties, baseCrs, conversion, DefaultCartesianCS.PROJECTED);
}
 
Example #15
Source File: TestUtils.java    From geowave with Apache License 2.0 5 votes vote down vote up
public static MathTransform transformFromCrs(final CoordinateReferenceSystem crs) {
  MathTransform mathTransform = null;
  if (crs != null) {
    try {
      mathTransform = CRS.findMathTransform(GeometryUtils.getDefaultCRS(), crs, true);
    } catch (final FactoryException e) {
      LOGGER.warn("Unable to create coordinate reference system transform", e);
    }
  }
  return mathTransform;
}
 
Example #16
Source File: ReprojectionUI.java    From snap-desktop with GNU General Public License v3.0 5 votes vote down vote up
private void updateCRS() {
    final Product sourceProduct = getSourceProduct();
    try {
        if (sourceProduct != null) {
            crs = crsSelectionPanel.getCrs(ProductUtils.getCenterGeoPos(sourceProduct));
            infoForm.setCenterPos(ProductUtils.getCenterGeoPos(sourceProduct));
            if (outputGeometryModel != null) {
                outputGeometryModel.setSourceProduct(sourceProduct);
            }
            if (crs != null) {
                infoForm.setCrsInfoText(crs.getName().getCode(), crs.toString());
            } else {
                infoForm.setCrsErrorText("No valid 'Coordinate Reference System' selected.");
            }
        } else {
            infoForm.setCrsErrorText("No source product selected.");
            crs = null;
        }
    } catch (FactoryException e) {
        infoForm.setCrsErrorText(e.getMessage());
        crs = null;
    }
    if (outputGeometryModel != null) {
        outputGeometryModel.setTargetCrs(crs);
    }
    updateOutputParameterState();
}
 
Example #17
Source File: GeometryUtility.java    From geofence with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Project geometry.
 *
 * @param originalGeom
 *            the original geom
 * @param srcCRSCode
 *            the src crs code
 * @param trgCRSCode
 *            the trg crs code
 * @return the geometry
 * @throws NoSuchAuthorityCodeException
 *             the no such authority code exception
 * @throws FactoryException
 *             the factory exception
 * @throws MismatchedDimensionException
 *             the mismatched dimension exception
 * @throws TransformException
 *             the transform exception
 */
public static Geometry projectGeometry(Geometry originalGeom, String srcCRSCode,
    String trgCRSCode) throws NoSuchAuthorityCodeException, FactoryException, MismatchedDimensionException,
    TransformException
{

    Geometry projectedGeometry = null;
    final MathTransform transform = CRS.findMathTransform(CRS.decode(srcCRSCode, true), CRS.decode(trgCRSCode, true), true);

    // converting geometries into a linear system
    try
    {
        projectedGeometry = JTS.transform(originalGeom, transform);
    }
    catch (Exception e)
    {
        GeometryFactory geometryFactory = new GeometryFactory(new PrecisionModel(
                    PrecisionModel.FLOATING), 4326);
        WKTReader reader = new WKTReader(geometryFactory);

        try
        {
            Polygon worldCutPolygon = (Polygon) reader.read("POLYGON((-180 -89.9, -180 89.9, 180 89.9, 180 -89.9, -180 -89.9))");

            projectedGeometry = JTS.transform(originalGeom.intersection(worldCutPolygon),
                    transform);
        }
        catch (Exception ex)
        {
            throw new RuntimeException(ex);
        }
    }

    return projectedGeometry;
}
 
Example #18
Source File: CustomCrsPanel.java    From snap-desktop with GNU General Public License v3.0 5 votes vote down vote up
private static List<String> retrieveCodes(Class<? extends GeodeticDatum> crsType, AuthorityFactory factory) {
    try {
        Set<String> localCodes = factory.getAuthorityCodes(crsType);
        return new ArrayList<>(localCodes);
    } catch (FactoryException ignore) {
        return Collections.emptyList();
    }
}
 
Example #19
Source File: FunctionAsGML.java    From GeoTriples with Apache License 2.0 5 votes vote down vote up
@Override
public Object execute(Object argument, QLTerm qlterm) throws SAXException, IOException, ParserConfigurationException, FactoryException, MalformedGeometryException, ParseException {

	if(qlterm.equals(QLTerm.SHP_CLASS) && argument instanceof org.gdal.ogr.Geometry ){
		org.gdal.ogr.Geometry gdalgeom=(org.gdal.ogr.Geometry )argument;

		return "<http://www.opengis.net/def/crs/EPSG/0/"+gdalgeom.GetSpatialReference().GetAttrValue("AUTHORITY", 1)+ "> "+gdalgeom.ExportToGML();
	}

	Geometry geometry = computeGeometry(argument, qlterm);
	return GTransormationFunctions.asGML((Geometry) geometry, CRS.decode("EPSG:"+Config.EPSG_CODE));
}
 
Example #20
Source File: GeoWaveFeatureCollection.java    From geowave with Apache License 2.0 5 votes vote down vote up
@Override
public int getCount() {
  if (query.getFilter().equals(Filter.INCLUDE)) {
    // GEOWAVE-60 optimization
    final Map<StatisticsId, InternalDataStatistics<SimpleFeature, ?, ?>> statsMap =
        reader.getTransaction().getDataStatistics();
    final StatisticsId id = CountDataStatistics.STATS_TYPE.newBuilder().build().getId();
    if (statsMap.containsKey(id)) {
      final CountDataStatistics stats = (CountDataStatistics) statsMap.get(id);
      if ((stats != null) && stats.isSet()) {
        return (int) stats.getCount();
      }
    }
  } else if (query.getFilter().equals(Filter.EXCLUDE)) {
    return 0;
  }

  QueryConstraints constraints;
  try {
    constraints = getQueryConstraints();

    return (int) reader.getCountInternal(
        constraints.jtsBounds,
        constraints.timeBounds,
        getFilter(query),
        constraints.limit);
  } catch (TransformException | FactoryException e) {

    LOGGER.warn("Unable to transform geometry, can't get count", e);
  }
  // fallback
  return 0;
}
 
Example #21
Source File: Wgs84Projection.java    From occurrence with Apache License 2.0 5 votes vote down vote up
/**
 * Parses the given datum or SRS code and constructs a full 2D geographic reference system.
 *
 * @return the parsed CRS or null if it can't be interpreted
 */
@VisibleForTesting
protected static CoordinateReferenceSystem parseCRS(String datum) {
  CoordinateReferenceSystem crs = null;
  ParseResult<Integer> epsgCode = PARSER.parse(datum);
  if (epsgCode.isSuccessful()) {
    final String code = "EPSG:" + epsgCode.getPayload();

    // first try to create a full fledged CRS from the given code
    try {
      crs = CRS.decode(code);

    } catch (FactoryException e) {
      // that didn't work, maybe it is *just* a datum
      try {
        GeodeticDatum dat = DATUM_FACTORY.createGeodeticDatum(code);
        crs = new DefaultGeographicCRS(dat, DefaultEllipsoidalCS.GEODETIC_2D);

      } catch (FactoryException e1) {
        // also not a datum, no further ideas, log error
        // swallow anything and return null instead
        LOG.info("No CRS or DATUM for given datum code >>{}<<: {}", datum, e1.getMessage());
      }
    }
  }
  return crs;
}
 
Example #22
Source File: FunctionSpatialDimension.java    From GeoTriples with Apache License 2.0 5 votes vote down vote up
@Override
public Object execute(Object argument, QLTerm qlterm) throws SAXException, IOException, ParserConfigurationException, FactoryException, MalformedGeometryException, ParseException {

	if(qlterm.equals(QLTerm.SHP_CLASS) && argument instanceof org.gdal.ogr.Geometry ){
		org.gdal.ogr.Geometry gdalgeom=(org.gdal.ogr.Geometry )argument;
		return String.valueOf(gdalgeom.GetDimension());
	}

	Geometry geometry = computeGeometry(argument, qlterm);
	return GTransormationFunctions.spatialDimension((Geometry) geometry);
}
 
Example #23
Source File: FunctionWithin.java    From GeoTriples with Apache License 2.0 5 votes vote down vote up
@Override
public Object execute(Object argument, QLTerm qlterm)
		throws SAXException, IOException, ParserConfigurationException, FactoryException,
		MalformedGeometryException, ParseException {

	return null;
}
 
Example #24
Source File: FunctionGreaterThan.java    From GeoTriples with Apache License 2.0 5 votes vote down vote up
@Override
	public List<? extends Object> execute(
			List<? extends Object> arguments,List<? extends QLTerm> qlterms) throws SAXException, IOException, ParserConfigurationException, FactoryException, MalformedGeometryException {
		List<String> valueList = new ArrayList<>();
//		System.out.println(arguments.get(0));
//		System.out.println(arguments.get(1));
//		System.out.println("result ");
		valueList.add(GTransormationFunctions.greaterThan(
				Double.valueOf(arguments.get(0).toString()),Double.valueOf(arguments.get(1).toString())));
//		System.out.println("GreaterThan("+ arguments.get(0) +","+arguments.get(1)+") ="+valueList.get(0));
		return valueList;
	}
 
Example #25
Source File: AbstractFunction.java    From GeoTriples with Apache License 2.0 5 votes vote down vote up
protected Geometry computeGeometry(Object object, QLTerm term) throws SAXException, IOException,
		ParserConfigurationException, NoSuchAuthorityCodeException, FactoryException, MalformedGeometryException, ParseException {

	if (!term.equals(QLTerm.SHP_CLASS) && cache.containsKey(object)) {
		return cache.get(object);
	}
	switch (term) {
	case SHP_CLASS:
		return (Geometry) object;
	case ROW_CLASS:
		Geometry result = computeGeometry((String) object, term);
		return result;
	case XPATH_CLASS:
		Geometry result1 = computeGeometry((String) object, term);
		cache.put(object, result1);
		return result1;
	case CSV_CLASS:
		Geometry result2 = computeGeometry((String) object, term);
		cache.put(object, result2);
		return result2;
	case JSONPATH_CLASS:
		Geometry result3 = computeGeometry((String) object, term);
		cache.put(object, result3);
		return result3;
	default:
		throw new MalformedGeometryException("GeoTriples cannot recognize this type of geometry");
	}

}
 
Example #26
Source File: FunctionCentroidX.java    From GeoTriples with Apache License 2.0 5 votes vote down vote up
@Override
public List<? extends Object> execute(
		List<? extends Object> arguments,List<? extends QLTerm> qlterms) throws SAXException, IOException, ParserConfigurationException, FactoryException, MalformedGeometryException, ParseException {
	List<String> valueList = new ArrayList<>();
	
	Geometry geometry = computeGeometry(arguments.get(0), qlterms.get(0));
	valueList.add(GTransormationFunctions.centroidx(
			(Geometry) geometry));
	return valueList;
}
 
Example #27
Source File: SpatialReferenceParameterValue.java    From constellation with Apache License 2.0 5 votes vote down vote up
@Override
public String toString() {
    String stringSRS = "No Value";
    if (spatialReference == null) {
        return stringSRS;
    } else {
        try {
            stringSRS = spatialReference.getSrs();
        } catch (final FactoryException ex) {
            Exceptions.printStackTrace(ex);
        }
        return stringSRS;
    }
}
 
Example #28
Source File: FunctionOverlaps.java    From GeoTriples with Apache License 2.0 5 votes vote down vote up
@Override
public List<? extends Object> execute(
		List<? extends Object> arguments,List<? extends QLTerm> qlterms) throws SAXException, IOException, ParserConfigurationException, FactoryException, MalformedGeometryException, ParseException {
	List<String> valueList = new ArrayList<>();
	
	Geometry geometry1 = computeGeometry(arguments.get(0), qlterms.get(0));
	Geometry geometry2 = computeGeometry(arguments.get(1), qlterms.get(1));
	valueList.add(GTransormationFunctions.overlaps(geometry1, geometry2));
	return valueList;
}
 
Example #29
Source File: DescribeSensorParserTest.java    From SensorWebClient with GNU General Public License v2.0 5 votes vote down vote up
public MyDescribeSensorParser(InputStream inputStream, SOSMetadata metadata) throws XmlException,
        IOException,
        XMLHandlingException,
        FactoryException {
    super(inputStream, metadata);
    // TODO Auto-generated constructor stub
}
 
Example #30
Source File: DescribeSensorParserTest.java    From SensorWebClient with GNU General Public License v2.0 5 votes vote down vote up
@Test 
public void shouldParseStrict4326PositionToCrs84Position() throws XmlException, IOException, FactoryException, TransformException {
    XmlObject sml = loadXmlFileViaClassloader(SML_POSITION_VECTOR_4326, getClass());
    DescribeSensorParser parser = createParserFromFile(sml, getSimpleMetadata());
    
    /*
     * We expect a lon/lat ordered coordinate as the inner CRS is CRS:84
     */
    Point actual = parser.buildUpSensorMetadataPosition();
    assertThat("X value (latitude) is incorrect.", actual.getX(), is(crs84Point.getX()));
    assertThat("Y value (longitude) is incorrect.", actual.getY(), is(crs84Point.getY()));
}