com.supermap.data
类 GeometriesRelation

java.lang.Object
  继承者 com.supermap.data.GeometriesRelation

public class GeometriesRelation
extends java.lang.Object

几何对象关系判断类,区别与空间查询的是,此类用于几何对象的判断,而不是数据集,实现原理上与空间查询相同,另外,此类只支持点、线、面的判断,适用于特定的场景 。

 public java.util.Map<GeoRegion, ArrayList<Point2D>> RegionsContainPoints(
                GeoRegion[] regions, Point2D[] points) {
        GeometriesRelation geometriesRelation = new GeometriesRelation();
 
        // 插入几何面对象
        for (int index = 0; index < regions.length; index++) {
                geometriesRelation.insert(regions[index], index);
        }
 
        java.util.Map<GeoRegion, ArrayList<Point2D>> result = new java.util.HashMap<GeoRegion, ArrayList<Point2D>>();
        for (int i = 0; i < points.length; i++) {
                // 找到所有包含当前点对象的面对象的值。
                int[] regionValues = geometriesRelation.matches(points[i],
                                SpatialQueryMode.CONTAIN);
                for (int j = 0; j < regionValues.length; j++) {
                        GeoRegion geoRegion = regions[regionValues[j]];
                        if (result.containsKey(geoRegion)) {
                                ArrayList<Point2D> outPoints = result.get(geoRegion);
                                outPoints.add(points[i]);
                                result.put(geoRegion, outPoints);
                        } else {
                                ArrayList<Point2D> outPoints = new ArrayList<Point2D>();
                                outPoints.add(points[i]);
                                result.put(geoRegion, outPoints);
                        }
                }
        }
        geometriesRelation.dispose();
        return result;
 }
 
 


构造方法摘要
GeometriesRelation()
          构造函数,构造一个几何对象关系判断对象。
 
方法摘要
 void dispose()
          释放 GeometriesRelation 占用的资源。
 Rectangle2D getBounds()
          获取 GeometriesRelation 中所有插入的几何对象的地理范围。
 GriddingLevel getGridding()
          获取面对象格网化等级。
 int getSourcesCount()
          获取 GeometriesRelation 中所有插入的几何对象数目。
 double getTolerance()
          获取节点容限。
 boolean insert(Geometry geometry, int value)
          插入一个用于被匹配的几何对象,被匹配对象在空间查询模式中为查询对象,例如,要进行面包含点对象查询,需要插入面对象到 GeometriesRelation 中,然后依次匹配得到与点对象满足包含关系的面对象。
 int[] intersectExtents(Rectangle2D extents)
          返回与指定矩形范围相交的所有对象,即对象的矩形范围相交。
 boolean isMatch(Geometry geometry, int srcValue, SpatialQueryMode mode)
          判断对象是否与指定对象满足空间关系
 boolean isMatch(Point2D point, int srcValue, SpatialQueryMode mode)
          判断二维点是否与指定对象满足空间关系
 int[] matches(Geometry[] geometries, SpatialQueryMode mode)
          找出与匹配对象满足空间关系的所有被匹配对象的值。
 int[] matches(Geometry geometry, SpatialQueryMode mode)
          找出与匹配对象满足空间关系的所有被匹配对象的值。
 int[] matches(Geometry geometry, SpatialQueryMode mode, int[] excludes)
          找出与匹配对象满足空间关系的所有被匹配对象的值。
 int[] matches(Point2D[] points, SpatialQueryMode mode)
          找出与二维点数组满足空间关系的所有被匹配对象的值
 int[] matches(Point2D point, SpatialQueryMode mode)
          找出与点对象满足空间关系的所有被匹配对象的值。
 int[] matches(Point2D point, SpatialQueryMode mode, int[] excludes)
          找出与点对象满足空间关系的所有被匹配对象的值。
 void setGridding(GriddingLevel level)
          设置面对象格网化等级。
 void setTolerance(double interval)
          设置节点容限。
 
从类 java.lang.Object 继承的方法
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

构造方法详细信息

GeometriesRelation

public GeometriesRelation()
构造函数,构造一个几何对象关系判断对象。

方法详细信息

dispose

public void dispose()
释放 GeometriesRelation 占用的资源。


setTolerance

public void setTolerance(double interval)
设置节点容限。

参数:
interval - 节点容限

getTolerance

public double getTolerance()
获取节点容限。

返回:
节点容限。

getGridding

public GriddingLevel getGridding()
获取面对象格网化等级。默认不做面对象格网化。

返回:
面对象格网化等级。

setGridding

public void setGridding(GriddingLevel level)
设置面对象格网化等级。默认不做面对象格网化。

参数:
level - 格网化等级。

getSourcesCount

public int getSourcesCount()
获取 GeometriesRelation 中所有插入的几何对象数目。

返回:
几何对象数目。

getBounds

public Rectangle2D getBounds()
获取 GeometriesRelation 中所有插入的几何对象的地理范围。

返回:
地理范围。

insert

public boolean insert(Geometry geometry,
                      int value)
插入一个用于被匹配的几何对象,被匹配对象在空间查询模式中为查询对象,例如,要进行面包含点对象查询,需要插入面对象到 GeometriesRelation 中,然后依次匹配得到与点对象满足包含关系的面对象。

参数:
geometry - 被匹配的几何对象,必须是点线面
value - 被匹配的值,是一个唯一值,且必须大于等于0,比如几何对象的 ID 等。
返回:
插入成功返回 true,否则返回 false。

matches

public int[] matches(Geometry geometry,
                     SpatialQueryMode mode)
找出与匹配对象满足空间关系的所有被匹配对象的值。

参数:
geometry - 匹配空间对象
mode - 空间查询模式
返回:
被匹配对象的值。

matches

public int[] matches(Geometry[] geometries,
                     SpatialQueryMode mode)
找出与匹配对象满足空间关系的所有被匹配对象的值。结果返回的形式为: 结果数目,结果IDs,结果数目,结果IDs,0,结果数目,结果IDs。

参数:
geometries - 匹配空间对象数组
mode - 空间查询模式
返回:
被匹配对象的值。

matches

public int[] matches(Point2D point,
                     SpatialQueryMode mode)
找出与点对象满足空间关系的所有被匹配对象的值。

参数:
point - 要进行匹配的二维点
mode - 空间查询模式
返回:
被匹配对象的值。

matches

public int[] matches(Point2D[] points,
                     SpatialQueryMode mode)
找出与二维点数组满足空间关系的所有被匹配对象的值

参数:
points - 结果返回的形式为: 结果数目,结果IDs,结果数目,结果IDs,0,结果数目,结果IDs。
mode - 空间查询模式
返回:
被匹配对象的值。

matches

public int[] matches(Geometry geometry,
                     SpatialQueryMode mode,
                     int[] excludes)
找出与匹配对象满足空间关系的所有被匹配对象的值。

参数:
geometry - 匹配空间对象
mode - 空间查询模式
excludes - 排除的值,即不参与匹配运算。
返回:
被匹配对象的值。

matches

public int[] matches(Point2D point,
                     SpatialQueryMode mode,
                     int[] excludes)
找出与点对象满足空间关系的所有被匹配对象的值。

参数:
point - 要进行匹配的二维点
mode - 空间查询模式
excludes - 要进行匹配的二维点
返回:
被匹配对象的值。

isMatch

public boolean isMatch(Point2D point,
                       int srcValue,
                       SpatialQueryMode mode)
判断二维点是否与指定对象满足空间关系

参数:
point - 要进行匹配的二维点
srcValue - 被匹配对象的值
mode - 匹配的空间查询模式
返回:
如果点与指定对象满足空间关系返回true,否则为false。

isMatch

public boolean isMatch(Geometry geometry,
                       int srcValue,
                       SpatialQueryMode mode)
判断对象是否与指定对象满足空间关系

参数:
geometry - 要进行匹配的对象
srcValue - 被匹配对象的值
mode - 匹配的空间查询模式
返回:
如果指定对象与指定对象满足空间关系返回true,否则为false。

intersectExtents

public int[] intersectExtents(Rectangle2D extents)
返回与指定矩形范围相交的所有对象,即对象的矩形范围相交。

参数:
extents - 指定的矩形范围
返回:
与指定的矩形范围相交的对象。