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

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

/*
 * 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.Geometry;
import org.geolatte.geom.Point;

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

/**
 * A Surface is a 2-dimensional geometric object.
 *
 * @author tiwe
 *
 * @param 
 */
public abstract class SurfaceExpression extends GeometryExpression {

    private static final long serialVersionUID = 3534197011234723698L;

    @Nullable
    private volatile PointExpression centroid, pointOnSurface;

    @Nullable
    private volatile NumberExpression area;

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

    /**
     * The area of this Surface, as measured in the spatial reference system of this Surface.
     *
     * @return
     */
    public NumberExpression area() {
        if (area == null) {
            area = NumberOperation.create(Double.class, SpatialOps.AREA, mixin);
        }
        return area;
    }

    /**
     * The mathematical centroid for this Surface as a Point. The result is not guaranteed to
     * be on this Surface.
     *
     * @return
     */
    public PointExpression centroid() {
        if (centroid == null) {
            centroid = PointOperation.create(Point.class, SpatialOps.CENTROID, mixin);
        }
        return centroid;
    }

    /**
     * A Point guaranteed to be on this Surface.
     *
     * @return
     */
    public PointExpression pointOnSurface() {
        if (pointOnSurface == null) {
            pointOnSurface = PointOperation.create(Point.class, SpatialOps.POINT_ON_SURFACE, mixin);
        }
        return pointOnSurface;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy