当前位置: 首页>>代码示例>>Java>>正文


Java GeoComputation类代码示例

本文整理汇总了Java中org.meteoinfo.geoprocess.GeoComputation的典型用法代码示例。如果您正苦于以下问题:Java GeoComputation类的具体用法?Java GeoComputation怎么用?Java GeoComputation使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


GeoComputation类属于org.meteoinfo.geoprocess包,在下文中一共展示了GeoComputation类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: maskout

import org.meteoinfo.geoprocess.GeoComputation; //导入依赖的package包/类
/**
 * Mask out grid data with polygon shapes
 *
 * @param polygons The polygon shapes
 * @return Maskouted grid data
 */
public GridData maskout(List<PolygonShape> polygons) {
    int xNum = this.getXNum();
    int yNum = this.getYNum();

    GridData cGrid = new GridData(this);
    for (int i = 0; i < yNum; i++) {
        for (int j = 0; j < xNum; j++) {
            if (GeoComputation.pointInPolygons(polygons, new PointD(xArray[j], yArray[i]))) {
                cGrid.data[i][j] = data[i][j];
            } else {
                cGrid.data[i][j] = missingValue;
            }
        }
    }

    return cGrid;
}
 
开发者ID:meteoinfo,项目名称:MeteoInfoLib,代码行数:24,代码来源:GridData.java

示例2: selectShapes

import org.meteoinfo.geoprocess.GeoComputation; //导入依赖的package包/类
/**
 * Select shapes by a polygon shape
 *
 * @param polygonShape The polygon shape
 * @return Selected shape indexes
 */
public List<Integer> selectShapes(PolygonShape polygonShape) {
    List<Integer> selIdxs = new ArrayList<>();
    for (int i = 0; i < _shapeList.size(); i++) {
        boolean isIn = false;
        List<PointD> points = (List<PointD>) _shapeList.get(i).getPoints();
        for (PointD aPoint : points) {
            if (GeoComputation.pointInPolygon(polygonShape, aPoint)) {
                isIn = true;
                break;
            }
        }

        if (isIn) {
            _shapeList.get(i).setSelected(true);
            selIdxs.add(i);
        }
    }

    return selIdxs;
}
 
开发者ID:meteoinfo,项目名称:MeteoInfoLib,代码行数:27,代码来源:VectorLayer.java

示例3: selectPolygonHole

import org.meteoinfo.geoprocess.GeoComputation; //导入依赖的package包/类
/**
 * Get polygon hole index by point
 *
 * @param p The point
 * @return PolygonShape and polygon hole index
 */
public Object[] selectPolygonHole(PointD p) {
    for (Shape shape : _shapeList) {
        int i = 0;
        for (Polygon poly : ((PolygonShape) shape).getPolygons()) {
            if (poly.hasHole()) {
                if (GeoComputation.pointInPolygon(poly.getOutLine(), p)) {
                    int j = 0;
                    for (List<? extends PointD> hole : poly.getHoleLines()) {
                        if (GeoComputation.pointInPolygon(hole, p)) {
                            return new Object[]{shape, i, j};
                        }
                        j += 1;
                    }
                }
            }
            i += 1;
        }
    }
    return null;
}
 
开发者ID:meteoinfo,项目名称:MeteoInfoLib,代码行数:27,代码来源:VectorLayer.java

示例4: selectShape

import org.meteoinfo.geoprocess.GeoComputation; //导入依赖的package包/类
/**
 * Select polygon shape
 *
 * @param layer Polygon layer
 * @param p The point
 * @return Selected polygon shape
 */
public PolygonShape selectShape(VectorLayer layer, PointF p) {
    float sX = p.X;
    float sY = p.Y;
    double[] projXY = screenToProj((double) p.X, p.Y);
    double projX = projXY[0];
    double projY = projXY[1];
    double[] sXY;
    if (_projection.isLonLatMap()) {
        if (projX < layer.getExtent().minX) {
            if (layer.getExtent().minX > -360 && layer.getExtent().maxX > 0) {
                sXY = projToScreen(projX, projY, 360);
                sX = (float) sXY[0];
                sY = (float) sXY[1];
            }
        }
        if (projX > layer.getExtent().maxX) {
            if (layer.getExtent().maxX < 360 && layer.getExtent().minX < 0) {
                sXY = projToScreen(projX, projY, -360);
                sX = (float) sXY[0];
                sY = (float) sXY[1];
            }
        }
    }

    projXY = screenToProj((double) sX, sY);
    projX = projXY[0];
    projY = projXY[1];

    for (int i = 0; i < layer.getShapeNum(); i++) {
        PolygonShape shape = (PolygonShape) layer.getShapes().get(i);
        if (GeoComputation.pointInPolygon(shape, new PointD(projX, projY))) {
            return shape;
        }
    }
    return null;
}
 
开发者ID:meteoinfo,项目名称:MeteoInfoLib,代码行数:44,代码来源:MapView.java

示例5: maskout

import org.meteoinfo.geoprocess.GeoComputation; //导入依赖的package包/类
/**
 * Maskout station data
 *
 * @param polygonShape Mask polygon shape
 * @return Result station data
 */
public StationData maskout(PolygonShape polygonShape) {
    StationData stData = new StationData();
    stData.projInfo = this.projInfo;
    stData.missingValue = this.missingValue;
    for (int i = 0; i < this.getStNum(); i++) {
        if (GeoComputation.pointInPolygon(polygonShape, new PointD(this.getX(i), this.getY(i)))) {
            stData.addData(this.getStid(i), this.getX(i), this.getY(i), this.getValue(i));
        }
    }

    return stData;
}
 
开发者ID:meteoinfo,项目名称:MeteoInfoLib,代码行数:19,代码来源:StationData.java

示例6: maskin

import org.meteoinfo.geoprocess.GeoComputation; //导入依赖的package包/类
/**
 * Maskin station data
 *
 * @param polygonShape Mask polygon shape
 * @return Result station data
 */
public StationData maskin(PolygonShape polygonShape) {
    StationData stData = new StationData();
    stData.projInfo = this.projInfo;
    stData.missingValue = this.missingValue;
    for (int i = 0; i < this.getStNum(); i++) {
        if (!GeoComputation.pointInPolygon(polygonShape, new PointD(this.getX(i), this.getY(i)))) {
            stData.addData(this.getStid(i), this.getX(i), this.getY(i), this.getValue(i));
        }
    }

    return stData;
}
 
开发者ID:meteoinfo,项目名称:MeteoInfoLib,代码行数:19,代码来源:StationData.java

示例7: maskout

import org.meteoinfo.geoprocess.GeoComputation; //导入依赖的package包/类
/**
 * Maskout function
 *
 * @param a Array a
 * @param x X Array
 * @param y Y Array
 * @param polygons Polygons for maskout
 * @return Result array with cell values of missing outside polygons
 */
public static Array maskout(Array a, Array x, Array y, List<PolygonShape> polygons) {
    Array r = Array.factory(a.getDataType(), a.getShape());
    for (int i = 0; i < a.getSize(); i++) {
        if (GeoComputation.pointInPolygons(polygons, new PointD(x.getDouble(i), y.getDouble(i)))) {
            r.setObject(i, a.getObject(i));
        } else {
            r.setObject(i, Double.NaN);
        }
    }
    return r;
}
 
开发者ID:meteoinfo,项目名称:MeteoInfoLib,代码行数:21,代码来源:ArrayMath.java

示例8: maskout_Remove

import org.meteoinfo.geoprocess.GeoComputation; //导入依赖的package包/类
/**
 * Maskout function
 *
 * @param a Array a
 * @param x X Array
 * @param y Y Array
 * @param polygons Polygons for maskout
 * @return Result arrays removing cells outside polygons
 */
public static Array[] maskout_Remove(Array a, Array x, Array y, List<PolygonShape> polygons) {
    List<Object> rdata = new ArrayList<>();
    List<Double> rxdata = new ArrayList<>();
    List<Double> rydata = new ArrayList<>();
    for (int i = 0; i < a.getSize(); i++) {
        if (GeoComputation.pointInPolygons(polygons, new PointD(x.getDouble(i), y.getDouble(i)))) {
            rdata.add(a.getObject(i));
            rxdata.add(x.getDouble(i));
            rydata.add(y.getDouble(i));
        }
    }

    int n = rdata.size();
    int[] shape = new int[1];
    shape[0] = n;
    Array r = Array.factory(a.getDataType(), shape);
    Array rx = Array.factory(x.getDataType(), shape);
    Array ry = Array.factory(y.getDataType(), shape);
    for (int i = 0; i < n; i++) {
        r.setObject(i, rdata.get(i));
        rx.setDouble(i, rxdata.get(i));
        ry.setDouble(i, rydata.get(i));
    }

    return new Array[]{r, rx, ry};
}
 
开发者ID:meteoinfo,项目名称:MeteoInfoLib,代码行数:36,代码来源:ArrayMath.java

示例9: setHoleLine

import org.meteoinfo.geoprocess.GeoComputation; //导入依赖的package包/类
/**
 * Set a hole line
 * @param idx Index
 * @param holeLine The hole line
 */
public void setHoleLine(int idx, List<? extends PointD> holeLine){
    if (GeoComputation.isClockwise(holeLine)) {
        Collections.reverse(holeLine);
    }
    _holeLines.set(idx, holeLine);
}
 
开发者ID:meteoinfo,项目名称:MeteoInfoLib,代码行数:12,代码来源:Polygon.java

示例10: addHole

import org.meteoinfo.geoprocess.GeoComputation; //导入依赖的package包/类
/**
 * Add a hole line
 *
 * @param points point list
 */
public void addHole(List<? extends PointD> points) {
    if (GeoComputation.isClockwise(points)) {
        Collections.reverse(points);
    }
    _holeLines.add(points);
}
 
开发者ID:meteoinfo,项目名称:MeteoInfoLib,代码行数:12,代码来源:Polygon.java

示例11: getArea

import org.meteoinfo.geoprocess.GeoComputation; //导入依赖的package包/类
/**
 * Get area
 *
 * @return area
 */
public double getArea() {
    double area = 0.0;
    for (Polygon aPG : _polygons) {
        area += GeoComputation.getArea(aPG.getOutLine());
        for (List<? extends PointD> hole : aPG.getHoleLines()) {
            area -= GeoComputation.getArea(hole);
        }
    }
    
    return area;
}
 
开发者ID:meteoinfo,项目名称:MeteoInfoLib,代码行数:17,代码来源:PolygonShape.java

示例12: getSphericalArea

import org.meteoinfo.geoprocess.GeoComputation; //导入依赖的package包/类
/**
 * Get spherical area
 *
 * @return spherical area
 */
public double getSphericalArea() {
    double area = 0.0;
    for (Polygon aPG : _polygons) {
        area += GeoComputation.sphericalPolygonArea(aPG.getOutLine());
        for (List<? extends PointD> hole : aPG.getHoleLines()) {
            area -= GeoComputation.sphericalPolygonArea(hole);
        }
    }
    
    return area;
}
 
开发者ID:meteoinfo,项目名称:MeteoInfoLib,代码行数:17,代码来源:PolygonShape.java

示例13: clip_bak

import org.meteoinfo.geoprocess.GeoComputation; //导入依赖的package包/类
/**
 * Clip the layer by clipping polygons
 *
 * @param clipPolys Clipping polygons
 * @return Clipped result layer
 */
public VectorLayer clip_bak(List<PolygonShape> clipPolys) {
    VectorLayer newLayer = (VectorLayer) this.cloneValue();
    DataTable aTable = new DataTable();
    for (DataColumn aDC : this.getAttributeTable().getTable().getColumns()) {
        Field bDC = new Field(aDC.getColumnName(), aDC.getDataType());
        aTable.getColumns().add(bDC);
    }

    newLayer.setShapes(new ArrayList<Shape>());
    for (PolygonShape aPGS : clipPolys) {
        for (int i = 0; i < this.getShapeNum(); i++) {
            Shape bShape = this.getShapes().get(i);
            DataRow aDR = this.getAttributeTable().getTable().getRows().get(i);
            for (Polygon aPolygon : aPGS.getPolygons()) {
                Shape clipShape = GeoComputation.clipShape(bShape, aPolygon.getOutLine());
                if (clipShape != null) {
                    newLayer.addShape(clipShape);
                    try {
                        aTable.addRow((DataRow) aDR.clone());
                    } catch (Exception ex) {
                        Logger.getLogger(VectorLayer.class.getName()).log(Level.SEVERE, null, ex);
                    }
                }
            }
        }
    }

    newLayer.getAttributeTable().setTable(aTable);
    newLayer.setLegendScheme((LegendScheme) this.getLegendScheme().clone());
    newLayer.setTransparency(this.getTransparency());

    return newLayer;
}
 
开发者ID:meteoinfo,项目名称:MeteoInfoLib,代码行数:40,代码来源:VectorLayer.java

示例14: interpolation_Surface_bak

import org.meteoinfo.geoprocess.GeoComputation; //导入依赖的package包/类
/**
 * Interpolate with surface method
 *
 * @param x_s scatter X array
 * @param y_s scatter Y array
 * @param a scatter value array
 * @param X x coordinate
 * @param Y y coordinate
 * @return grid data
 */
public static Array interpolation_Surface_bak(Array x_s, Array y_s, Array a, Array X, Array Y) {
    int rowNum, colNum, xn, yn;
    int[] shape = x_s.getShape();
    colNum = shape[1];
    rowNum = shape[0];
    xn = (int) X.getSize();
    yn = (int) Y.getSize();
    Array r = Array.factory(DataType.DOUBLE, new int[]{yn, xn});
    double x, y;
    boolean isIn;

    PolygonShape[][] polygons = new PolygonShape[rowNum - 1][colNum - 1];
    for (int i = 0; i < rowNum - 1; i++) {
        for (int j = 0; j < colNum - 1; j++) {
            PolygonShape ps = new PolygonShape();
            List<PointD> points = new ArrayList<>();
            points.add(new PointD(x_s.getDouble(i * colNum + j), y_s.getDouble(i * colNum + j)));
            points.add(new PointD(x_s.getDouble((i + 1) * colNum + j), y_s.getDouble((i + 1) * colNum + j)));
            points.add(new PointD(x_s.getDouble((i + 1) * colNum + j + 1), y_s.getDouble((i + 1) * colNum + j + 1)));
            points.add(new PointD(x_s.getDouble(i * colNum + j + 1), y_s.getDouble(i * colNum + j + 1)));
            points.add((PointD) points.get(0).clone());
            ps.setPoints(points);
            polygons[i][j] = ps;
        }
    }

    for (int i = 0; i < yn; i++) {
        y = Y.getDouble(i);
        for (int j = 0; j < xn; j++) {
            x = X.getDouble(j);
            isIn = false;
            for (int ii = 0; ii < rowNum - 1; ii++) {
                for (int jj = 0; jj < colNum - 1; jj++) {
                    if (GeoComputation.pointInPolygon(polygons[ii][jj], x, y)) {
                        r.setDouble(i * xn + j, a.getDouble(ii * colNum + jj));
                        isIn = true;
                        break;
                    }
                }
                if (isIn) {
                    break;
                }
            }
            if (!isIn) {
                r.setDouble(i * xn + j, Double.NaN);
            }
        }
    }

    return r;
}
 
开发者ID:meteoinfo,项目名称:MeteoInfoLib,代码行数:62,代码来源:ArrayUtil.java

示例15: selectGraphics

import org.meteoinfo.geoprocess.GeoComputation; //导入依赖的package包/类
/**
 * Select graphics by an extent
 * @param aExtent The extent
 * @return Selected graphics
 */
public GraphicCollection selectGraphics(Extent aExtent) {
    GraphicCollection selectedGraphics = new GraphicCollection();
    int i, j;
    PointD aPoint = new PointD();
    aPoint.X = (aExtent.minX + aExtent.maxX) / 2;
    aPoint.Y = (aExtent.minY + aExtent.maxY) / 2;

    for (Graphic aGraphic : this.graphics) {
        switch (aGraphic.getShape().getShapeType()) {
            case Point:
                PointShape aPS = (PointShape) aGraphic.getShape();
                if (MIMath.pointInExtent(aPS.getPoint(), aExtent)) {
                    selectedGraphics.add(aGraphic);
                }
                break;
            case Polyline:
            case PolylineZ:
                PolylineShape aPLS = (PolylineShape) aGraphic.getShape();
                if (MIMath.isExtentCross(aExtent, aPLS.getExtent())) {
                    for (j = 0; j < aPLS.getPoints().size(); j++) {
                        aPoint = aPLS.getPoints().get(j);
                        if (MIMath.pointInExtent(aPoint, aExtent)) {
                            selectedGraphics.add(aGraphic);
                            break;
                        }
                    }
                }
                break;
            case Polygon:
            case Rectangle:
                PolygonShape aPGS = (PolygonShape) aGraphic.getShape();
                if (!(aPGS.getPartNum() > 1)) {
                    if (GeoComputation.pointInPolygon((List<PointD>)aPGS.getPoints(), aPoint)) {
                        selectedGraphics.add(aGraphic);
                    }
                } else {
                    for (int p = 0; p < aPGS.getPartNum(); p++) {
                        ArrayList pList = new ArrayList();
                        if (p == aPGS.getPartNum() - 1) {
                            for (int pp = aPGS.parts[p]; pp < aPGS.getPointNum(); pp++) {
                                pList.add(aPGS.getPoints().get(pp));
                            }
                        } else {
                            for (int pp = aPGS.parts[p]; pp < aPGS.parts[p + 1]; pp++) {
                                pList.add(aPGS.getPoints().get(pp));
                            }
                        }
                        if (GeoComputation.pointInPolygon(pList, aPoint)) {
                            selectedGraphics.add(aGraphic);
                            break;
                        }
                    }
                }
                break;
        }
    }

    return selectedGraphics;
}
 
开发者ID:meteoinfo,项目名称:MeteoInfoLib,代码行数:65,代码来源:GraphicCollection.java


注:本文中的org.meteoinfo.geoprocess.GeoComputation类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。