All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.mysema.query.spatial.PolygonExpression Maven / Gradle / Ivy

The newest version!
/*
 * Copyright 2015, The Querydsl Team (http://www.querydsl.com/team)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * http://www.apache.org/licenses/LICENSE-2.0
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.mysema.query.spatial;

import javax.annotation.Nullable;

import org.geolatte.geom.LineString;
import org.geolatte.geom.Polygon;

import com.mysema.query.types.ConstantImpl;
import com.mysema.query.types.Expression;
import com.mysema.query.types.expr.NumberExpression;
import com.mysema.query.types.expr.NumberOperation;

/**
 * A Polygon is a planar Surface defined by 1 exterior boundary and 0 or more interior boundaries. Each interior
 * boundary defines a hole in the Polygon. A Triangle is a polygon with 3 distinct, non-collinear vertices and no
 * interior boundary.
 *
 * @author tiwe
 *
 * @param 
 */
public abstract class PolygonExpression extends SurfaceExpression {

    private static final long serialVersionUID = 7544382956232485312L;

    @Nullable
    private volatile NumberExpression numInteriorRing;

    @Nullable
    private volatile LineStringExpression exterorRing;

    public PolygonExpression(Expression mixin) {
        super(mixin);
    }

    /**
     * Returns the exterior ring of this Polygon.
     *
     * @return
     */
    public LineStringExpression exteriorRing() {
        if (exterorRing == null) {
            exterorRing = LineStringOperation.create(LineString.class, SpatialOps.EXTERIOR_RING, mixin);
        }
        return exterorRing;
    }

    /**
     * Returns the number of interior rings in this Polygon.
     *
     * @return
     */
    public NumberExpression numInteriorRing() {
        if (numInteriorRing == null) {
            numInteriorRing = NumberOperation.create(Integer.class, SpatialOps.NUM_INTERIOR_RING, mixin);
        }
        return numInteriorRing;
    }

    /**
     * Returns the N th interior ring for this Polygon as a LineString.
     *
     * @param idx
     * @return
     */
    public LineStringExpression interiorRingN(int idx) {
        return LineStringOperation.create(LineString.class, SpatialOps.INTERIOR_RINGN, mixin, ConstantImpl.create(idx));
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy