Examples of GeometryAttribute


Examples of org.geotools.xacml.geoxacml.attr.GeometryAttribute

        AttributeValue[] argValues = new AttributeValue[inputs.size()];
        EvaluationResult result = evalArgs(inputs, context, argValues);
        if (result != null)
            return result;

        GeometryAttribute geomAttr = (GeometryAttribute) (argValues[0]);

        boolean evalResult = false;

        try {
            Geometry geom = geomAttr.getGeometry();
            if (geom.isEmpty())
                evalResult = true;
            else if (geom instanceof Point || geom instanceof MultiPoint)
                evalResult = true;
            else if (geom instanceof LineString)
View Full Code Here

Examples of org.geotools.xacml.geoxacml.attr.GeometryAttribute

        AttributeValue[] argValues = new AttributeValue[inputs.size()];
        EvaluationResult result = evalArgs(inputs, context, argValues);
        if (result != null)
            return result;

        GeometryAttribute geomAttr = (GeometryAttribute) (argValues[0]);

        Geometry resultGeom = null;

        try {
            resultGeom = geomAttr.getGeometry().getCentroid();
        } catch (Throwable t) {
            return exceptionError(t);
        }

        GeometryAttribute resultAttr = null;

        try {
            resultAttr = new GeometryAttribute(resultGeom, geomAttr.getSrsName(), null, null, null);
        } catch (URISyntaxException e) {
            // should not happend
        }
        return new EvaluationResult(resultAttr);
View Full Code Here

Examples of org.geotools.xacml.geoxacml.attr.GeometryAttribute

        AttributeValue[] argValues = new AttributeValue[inputs.size()];
        EvaluationResult result = evalArgs(inputs, context, argValues);
        if (result != null)
            return result;

        GeometryAttribute geomAttr = (GeometryAttribute) (argValues[0]);

        Geometry resultGeom = null;

        try {
            resultGeom = geomAttr.getGeometry().getBoundary();
        } catch (Throwable t) {
            return exceptionError(t);
        }

        return createGeometryInBagResult(resultGeom, geomAttr.getSrsName());

    }
View Full Code Here

Examples of org.geotools.xacml.geoxacml.attr.GeometryAttribute

        AttributeValue[] argValues = new AttributeValue[inputs.size()];
        EvaluationResult result = evalArgs(inputs, context, argValues);
        if (result != null)
            return result;

        GeometryAttribute geomAttr1 = (GeometryAttribute) (argValues[0]);
        GeometryAttribute geomAttr2 = (GeometryAttribute) (argValues[1]);

        double distance = 0;

        try {
            distance = geomAttr1.getGeometry().distance(geomAttr2.getGeometry());
        } catch (Throwable t) {
            return exceptionError(t);
        }

        return new EvaluationResult(new DoubleAttribute(distance));
View Full Code Here

Examples of org.geotools.xacml.geoxacml.attr.GeometryAttribute

            boolean[] paramIsBag, String returnType, boolean returnsBag) {
        super(functionName, functionId, paramTypes, paramIsBag, returnType, returnsBag);
    }

    protected EvaluationResult createGeometryInBagResult(Geometry resultGeom, String targetSrsName) {
        GeometryAttribute resultGeomAttr = null;

        try {
            resultGeomAttr = new GeometryAttribute(resultGeom, targetSrsName, null, null, null);
        } catch (URISyntaxException e) {
            // should not happen
        }
        Set<AttributeValue> set = new HashSet<AttributeValue>();
        set.add(resultGeomAttr);
        BagAttribute bag = new BagAttribute(resultGeomAttr.getType(), set);
        return new EvaluationResult(bag);
    }
View Full Code Here

Examples of org.geotools.xacml.geoxacml.attr.GeometryAttribute

     *             1) One attribute has a srsName, the other not 2) a CRS is not decodeable
     *
     *             If we need a transformation, both geometries are transformd to WGS84
     */
    protected String transformOnDemand(GeometryAttribute array[]) throws GeoXACMLException {
        GeometryAttribute attr1 = array[0];
        GeometryAttribute attr2 = array[1];

        if (attr1.getSrsName() == null && attr2.getSrsName() == null)
            return null;

        if ((attr1.getSrsName() == null && attr2.getSrsName() != null)
                || (attr1.getSrsName() != null && attr2.getSrsName() == null)) {
            throw new GeoXACMLException("Missing srsName");
        }

        if (attr1.getSrsName().equalsIgnoreCase(attr2.getSrsName()))
            return attr1.getSrsName();

        CoordinateReferenceSystem[] crsArray = new CoordinateReferenceSystem[2];
        crsArray[0] = decodeCRS(array[0].getSrsName());
        crsArray[1] = decodeCRS(array[1].getSrsName());

        for (int i = 0; i < crsArray.length; i++) { // check if not null
            if (crsArray[i] == null)
                throw new GeoXACMLException("Cannod decode " + array[i].getSrsName());
        }

        if (CRS.equalsIgnoreMetadata(crsArray[0], crsArray[1])) // CRS are compatible
            return array[0].getSrsName();

        try {
            for (int i = 0; i < array.length; i++) {
                Geometry newGeom = transformToCommonCRS(array[i].getGeometry(), array[i]
                        .getSrsName(), crsArray[i]);
                if (newGeom != array[i].getGeometry()) { // geometry changed
                    GeometryAttribute newGeomAttr = new GeometryAttribute(newGeom, COMMON_CRS_NAME,
                            array[i].getGid(), array[i].getGmlVersion(), array[i].getType()
                                    .toString());
                    newGeomAttr.setSrsDimension(array[i].getSrsDimension());
                    array[i] = newGeomAttr;
                }
            }
        } catch (Exception e) {
            throw new GeoXACMLException(e);
View Full Code Here

Examples of org.geotools.xacml.geoxacml.attr.GeometryAttribute

        AttributeValue[] argValues = new AttributeValue[inputs.size()];
        EvaluationResult result = evalArgs(inputs, context, argValues);
        if (result != null)
            return result;

        GeometryAttribute geomAttr = (GeometryAttribute) (argValues[0]);

        boolean evalResult = false;

        try {
            evalResult = geomAttr.getGeometry().isValid();
        } catch (Throwable t) {
            return exceptionError(t);
        }
        return EvaluationResult.getInstance(evalResult);
View Full Code Here

Examples of org.geotools.xacml.geoxacml.attr.GeometryAttribute

        AttributeValue[] argValues = new AttributeValue[inputs.size()];
        EvaluationResult result = evalArgs(inputs, context, argValues);
        if (result != null)
            return result;

        GeometryAttribute geomAttr = (GeometryAttribute) (argValues[0]);

        double area = 0;

        try {
            area = geomAttr.getGeometry().getArea();
        } catch (Throwable t) {
            return exceptionError(t);
        }

        return new EvaluationResult(new DoubleAttribute(area));
View Full Code Here

Examples of org.geotools.xacml.geoxacml.attr.GeometryAttribute

        Result result = response.getResults().iterator().next();
        assertNotNull(result);
        Obligation obligation = result.getObligations().iterator().next();
        assertNotNull(obligation);
        Attribute assignment = obligation.getAssignments().iterator().next();
        GeometryAttribute geomAttr = (GeometryAttribute) assignment.getValue();
        assertNotNull(geomAttr.getGeometry());

    }
View Full Code Here

Examples of org.geotools.xacml.geoxacml.attr.GeometryAttribute

    protected static String RESOURCE_ZIP = "src/test/resources/resources.zip";

    public static GeometryAttribute getGeometryAttribute(AbstractPolicy p) {
        Rule rule = (Rule) p.getChildren().get(0);
        Apply apply = (Apply) rule.getCondition().getChildren().get(0);
        GeometryAttribute attr = (GeometryAttribute) apply.getChildren().get(1);
        return attr;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.