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


Java Envelope.getWidth方法代码示例

本文整理汇总了Java中com.vividsolutions.jts.geom.Envelope.getWidth方法的典型用法代码示例。如果您正苦于以下问题:Java Envelope.getWidth方法的具体用法?Java Envelope.getWidth怎么用?Java Envelope.getWidth使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.vividsolutions.jts.geom.Envelope的用法示例。


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

示例1: createFrame

import com.vividsolutions.jts.geom.Envelope; //导入方法依赖的package包/类
private void createFrame(Envelope env) {
    double deltaX = env.getWidth();
    double deltaY = env.getHeight();
    double offset = 0.0;
    if (deltaX > deltaY) {
        offset = deltaX * 10.0;
    } else {
        offset = deltaY * 10.0;
    }

    this.frameVertex[0] = new Vertex((env.getMaxX() + env.getMinX()) / 2.0, env
            .getMaxY()
            + offset);
    this.frameVertex[1] = new Vertex(env.getMinX() - offset, env.getMinY() - offset);
    this.frameVertex[2] = new Vertex(env.getMaxX() + offset, env.getMinY() - offset);

    this.frameEnv = new Envelope(this.frameVertex[0].getCoordinate(), this.frameVertex[1]
            .getCoordinate());
    this.frameEnv.expandToInclude(this.frameVertex[2].getCoordinate());
}
 
开发者ID:gegy1000,项目名称:Earth,代码行数:21,代码来源:QuadEdgeSubdivision.java

示例2: createEllipse

import com.vividsolutions.jts.geom.Envelope; //导入方法依赖的package包/类
/**
 * Creates an elliptical {@link Polygon}.
 * If the supplied envelope is square the
 * result will be a circle.
 *
 * @return an ellipse or circle
 */
public Polygon createEllipse() {

    Envelope env = this.dim.getEnvelope();
    double xRadius = env.getWidth() / 2.0;
    double yRadius = env.getHeight() / 2.0;

    double centreX = env.getMinX() + xRadius;
    double centreY = env.getMinY() + yRadius;

    Coordinate[] pts = new Coordinate[this.nPts + 1];
    int iPt = 0;
    for (int i = 0; i < this.nPts; i++) {
        double ang = i * (2 * Math.PI / this.nPts);
        double x = xRadius * Math.cos(ang) + centreX;
        double y = yRadius * Math.sin(ang) + centreY;
        pts[iPt++] = this.coord(x, y);
    }
    pts[iPt] = new Coordinate(pts[0]);

    LinearRing ring = this.geomFact.createLinearRing(pts);
    Polygon poly = this.geomFact.createPolygon(ring, null);
    return (Polygon) this.rotate(poly);
}
 
开发者ID:gegy1000,项目名称:Earth,代码行数:31,代码来源:GeometricShapeFactory.java

示例3: fastGetSharedAreaRatio

import com.vividsolutions.jts.geom.Envelope; //导入方法依赖的package包/类
/**
 * This is ten times faster than the absolutely correct
 * version above, and it's only off by an average of 1%.
 * Note that the first argument MUST be rectangular, or
 * your results will be meaningless.
 */
public static double fastGetSharedAreaRatio (Geometry geom1, Geometry geom2) {
    Envelope env1 = geom1.getEnvelopeInternal();
    if ((SimplePointInAreaLocator.locate(new Coordinate(env1.getMinX(),env1.getMinY()), geom2) == Location.INTERIOR) &&
        (SimplePointInAreaLocator.locate(new Coordinate(env1.getMaxX(),env1.getMaxY()), geom2) == Location.INTERIOR) &&
        (SimplePointInAreaLocator.locate(new Coordinate(env1.getMaxX(),env1.getMinY()), geom2) == Location.INTERIOR) &&
        (SimplePointInAreaLocator.locate(new Coordinate(env1.getMinX(),env1.getMaxY()), geom2) == Location.INTERIOR)) {
        // I suppose it is possible for a valid polygon geometry
        // to contain all four corners and share considerably less
        // than 100% of its area with the envelope in question.
        // But if you're that worried about correctness you
        // shouldn't be using this method in the first place.
        return 1.0;
    }
    double xInc = env1.getWidth() / 9.0;
    double yInc = env1.getHeight() / 9.0;
    double x = env1.getMinX();
    double y = env1.getMinY();
    double ct = 0;
    for (int i = 0; i < 10; i += 1) {
        y = env1.getMinY();
        for (int j = 0; j < 10; j += 1) {
            if (SimplePointInAreaLocator.locate(new Coordinate(x,y), geom2) == Location.INTERIOR) {
                ct += 1;
            }
            y += yInc;
        }
        x += xInc;
    }
    return (ct / 100.0);
}
 
开发者ID:ec-europa,项目名称:sumo,代码行数:37,代码来源:JTSUtil.java

示例4: computeBoundingBox

import com.vividsolutions.jts.geom.Envelope; //导入方法依赖的package包/类
private void computeBoundingBox() {
    Envelope vertexEnv = computeVertexEnvelope(this.initialVertices);
    Envelope segEnv = computeVertexEnvelope(this.segVertices);

    Envelope allPointsEnv = new Envelope(vertexEnv);
    allPointsEnv.expandToInclude(segEnv);

    double deltaX = allPointsEnv.getWidth() * 0.2;
    double deltaY = allPointsEnv.getHeight() * 0.2;

    double delta = Math.max(deltaX, deltaY);

    this.computeAreaEnv = new Envelope(allPointsEnv);
    this.computeAreaEnv.expandBy(delta);
}
 
开发者ID:gegy1000,项目名称:Earth,代码行数:16,代码来源:ConformingDelaunayTriangulator.java

示例5: diagonalSize

import com.vividsolutions.jts.geom.Envelope; //导入方法依赖的package包/类
public static double diagonalSize(Envelope env) {
    if (env.isNull()) {
        return 0.0;
    }

    double width = env.getWidth();
    double hgt = env.getHeight();
    return Math.sqrt(width * width + hgt * hgt);
}
 
开发者ID:gegy1000,项目名称:Earth,代码行数:10,代码来源:HausdorffSimilarityMeasure.java

示例6: computeQuadLevel

import com.vividsolutions.jts.geom.Envelope; //导入方法依赖的package包/类
public static int computeQuadLevel(Envelope env) {
    double dx = env.getWidth();
    double dy = env.getHeight();
    double dMax = dx > dy ? dx : dy;
    int level = DoubleBits.exponent(dMax) + 1;
    return level;
}
 
开发者ID:gegy1000,项目名称:Earth,代码行数:8,代码来源:Key.java

示例7: collectStats

import com.vividsolutions.jts.geom.Envelope; //导入方法依赖的package包/类
private void collectStats(Envelope itemEnv) {
    double delX = itemEnv.getWidth();
    if (delX < this.minExtent && delX > 0.0) {
        this.minExtent = delX;
    }

    double delY = itemEnv.getHeight();
    if (delY < this.minExtent && delY > 0.0) {
        this.minExtent = delY;
    }
}
 
开发者ID:gegy1000,项目名称:Earth,代码行数:12,代码来源:Quadtree.java

示例8: createArc

import com.vividsolutions.jts.geom.Envelope; //导入方法依赖的package包/类
/**
 * Creates an elliptical arc, as a {@link LineString}.
 * The arc is always created in a counter-clockwise direction.
 * This can easily be reversed if required by using
 * {#link LineString.reverse()}
 *
 * @param startAng start angle in radians
 * @param angExtent size of angle in radians
 * @return an elliptical arc
 */
public LineString createArc(
        double startAng,
        double angExtent) {
    Envelope env = this.dim.getEnvelope();
    double xRadius = env.getWidth() / 2.0;
    double yRadius = env.getHeight() / 2.0;

    double centreX = env.getMinX() + xRadius;
    double centreY = env.getMinY() + yRadius;

    double angSize = angExtent;
    if (angSize <= 0.0 || angSize > 2 * Math.PI) {
        angSize = 2 * Math.PI;
    }
    double angInc = angSize / (this.nPts - 1);

    Coordinate[] pts = new Coordinate[this.nPts];
    int iPt = 0;
    for (int i = 0; i < this.nPts; i++) {
        double ang = startAng + i * angInc;
        double x = xRadius * Math.cos(ang) + centreX;
        double y = yRadius * Math.sin(ang) + centreY;
        pts[iPt++] = this.coord(x, y);
    }
    LineString line = this.geomFact.createLineString(pts);
    return (LineString) this.rotate(line);
}
 
开发者ID:gegy1000,项目名称:Earth,代码行数:38,代码来源:GeometricShapeFactory.java

示例9: createArcPolygon

import com.vividsolutions.jts.geom.Envelope; //导入方法依赖的package包/类
/**
 * Creates an elliptical arc polygon.
 * The polygon is formed from the specified arc of an ellipse
 * and the two radii connecting the endpoints to the centre of the ellipse.
 *
 * @param startAng start angle in radians
 * @param angExtent size of angle in radians
 * @return an elliptical arc polygon
 */
public Polygon createArcPolygon(double startAng, double angExtent) {
    Envelope env = this.dim.getEnvelope();
    double xRadius = env.getWidth() / 2.0;
    double yRadius = env.getHeight() / 2.0;

    double centreX = env.getMinX() + xRadius;
    double centreY = env.getMinY() + yRadius;

    double angSize = angExtent;
    if (angSize <= 0.0 || angSize > 2 * Math.PI) {
        angSize = 2 * Math.PI;
    }
    double angInc = angSize / (this.nPts - 1);
    // double check = angInc * nPts;
    // double checkEndAng = startAng + check;

    Coordinate[] pts = new Coordinate[this.nPts + 2];

    int iPt = 0;
    pts[iPt++] = this.coord(centreX, centreY);
    for (int i = 0; i < this.nPts; i++) {
        double ang = startAng + angInc * i;

        double x = xRadius * Math.cos(ang) + centreX;
        double y = yRadius * Math.sin(ang) + centreY;
        pts[iPt++] = this.coord(x, y);
    }
    pts[iPt++] = this.coord(centreX, centreY);
    LinearRing ring = this.geomFact.createLinearRing(pts);
    Polygon poly = this.geomFact.createPolygon(ring, null);
    return (Polygon) this.rotate(poly);
}
 
开发者ID:gegy1000,项目名称:Earth,代码行数:42,代码来源:GeometricShapeFactory.java

示例10: createTileGeom

import com.vividsolutions.jts.geom.Envelope; //导入方法依赖的package包/类
/**
 * <p>Create geometry clipped and then converted to MVT 'extent' coordinates. Result
 * contains both clipped geometry (intersection) and transformed geometry for encoding to
 * MVT.</p>
 * <p>Allows specifying separate tile and clipping coordinates. {@code clipEnvelope} can be bigger
 * than {@code tileEnvelope} to have geometry exist outside the MVT tile extent.</p>
 *
 * @param geometryList   original 'source' geometry, passed through
 *                       {@link #flatFeatureList(Geometry)}
 * @param tileEnvelope   world coordinate bounds for tile, used for transforms
 * @param clipEnvelope   world coordinates to clip tile by
 * @param geomFactory    creates a geometry for the tile envelope
 * @param mvtLayerParams specifies vector tile properties
 * @param filter         geometry values that fail filter after transforms are removed
 * @return tile geometry result
 * @see TileGeomResult
 */
public static TileGeomResult createTileGeom(List<Geometry> geometryList,
                                            Envelope tileEnvelope,
                                            Envelope clipEnvelope,
                                            GeometryFactory geomFactory,
                                            MvtLayerParams mvtLayerParams,
                                            IGeometryFilter filter) {

  final Geometry tileClipGeom = geomFactory.toGeometry(clipEnvelope);

  final AffineTransformation t = new AffineTransformation();
  final double xDiff = tileEnvelope.getWidth();
  final double yDiff = tileEnvelope.getHeight();

  final double xOffset = -tileEnvelope.getMinX();
  final double yOffset = -tileEnvelope.getMinY();

  // Transform Setup: Shift to 0 as minimum value
  t.translate(xOffset, yOffset);

  // Transform Setup: Scale X and Y to tile extent values, flip Y values
  t.scale(1d / (xDiff / (double) mvtLayerParams.extent),
      -1d / (yDiff / (double) mvtLayerParams.extent));

  // Transform Setup: Bump Y values to positive quadrant
  t.translate(0d, (double) mvtLayerParams.extent);


  // The area contained in BOTH the 'original geometry', g, AND the 'clip envelope geometry' is
  // the 'tile geometry'
  final List<Geometry> intersectedGeoms = flatIntersection(tileClipGeom, geometryList);
  final List<Geometry> transformedGeoms = new ArrayList<>(intersectedGeoms.size());

  // Transform intersected geometry
  Geometry nextTransformGeom;
  Object nextUserData;
  for (Geometry nextInterGeom : intersectedGeoms) {
    nextUserData = nextInterGeom.getUserData();

    nextTransformGeom = t.transform(nextInterGeom);

    // Floating --> Integer, still contained within doubles
    nextTransformGeom.apply(RoundingFilter.INSTANCE);

    // TODO: Refactor line simplification
    // Can't use 0d, specify value < .5d
    nextTransformGeom = TopologyPreservingSimplifier.simplify(nextTransformGeom, .1d);

    nextTransformGeom.setUserData(nextUserData);

    // Apply filter on transformed geometry
    if (filter.accept(nextTransformGeom)) {
      transformedGeoms.add(nextTransformGeom);
    }
  }

  return new TileGeomResult(intersectedGeoms, transformedGeoms);
}
 
开发者ID:OrdnanceSurvey,项目名称:vt-support,代码行数:75,代码来源:JtsAdapter.java

示例11: createSineStar

import com.vividsolutions.jts.geom.Envelope; //导入方法依赖的package包/类
/**
 * Generates the geometry for the sine star
 *
 * @return the geometry representing the sine star
 */
public Geometry createSineStar() {
    Envelope env = this.dim.getEnvelope();
    double radius = env.getWidth() / 2.0;

    double armRatio = this.armLengthRatio;
    if (armRatio < 0.0) {
        armRatio = 0.0;
    }
    if (armRatio > 1.0) {
        armRatio = 1.0;
    }

    double armMaxLen = armRatio * radius;
    double insideRadius = (1 - armRatio) * radius;

    double centreX = env.getMinX() + radius;
    double centreY = env.getMinY() + radius;

    Coordinate[] pts = new Coordinate[this.nPts + 1];
    int iPt = 0;
    for (int i = 0; i < this.nPts; i++) {
        // the fraction of the way thru the current arm - in [0,1]
        double ptArcFrac = (i / (double) this.nPts) * this.numArms;
        double armAngFrac = ptArcFrac - Math.floor(ptArcFrac);

        // the angle for the current arm - in [0,2Pi]
        // (each arm is a complete sine wave cycle)
        double armAng = 2 * Math.PI * armAngFrac;
        // the current length of the arm
        double armLenFrac = (Math.cos(armAng) + 1.0) / 2.0;

        // the current radius of the curve (core + arm)
        double curveRadius = insideRadius + armMaxLen * armLenFrac;

        // the current angle of the curve
        double ang = i * (2 * Math.PI / this.nPts);
        double x = curveRadius * Math.cos(ang) + centreX;
        double y = curveRadius * Math.sin(ang) + centreY;
        pts[iPt++] = this.coord(x, y);
    }
    pts[iPt] = new Coordinate(pts[0]);

    LinearRing ring = this.geomFact.createLinearRing(pts);
    Polygon poly = this.geomFact.createPolygon(ring, null);
    return poly;
}
 
开发者ID:gegy1000,项目名称:Earth,代码行数:52,代码来源:SineStarFactory.java

示例12: setEnvelope

import com.vividsolutions.jts.geom.Envelope; //导入方法依赖的package包/类
public void setEnvelope(Envelope env) {
    this.width = env.getWidth();
    this.height = env.getHeight();
    this.base = new Coordinate(env.getMinX(), env.getMinY());
    this.centre = new Coordinate(env.centre());
}
 
开发者ID:gegy1000,项目名称:Earth,代码行数:7,代码来源:GeometricShapeFactory.java

示例13: createRandomCoord

import com.vividsolutions.jts.geom.Envelope; //导入方法依赖的package包/类
protected Coordinate createRandomCoord(Envelope env) {
    double x = env.getMinX() + env.getWidth() * Math.random();
    double y = env.getMinY() + env.getHeight() * Math.random();
    return this.createCoord(x, y);
}
 
开发者ID:gegy1000,项目名称:Earth,代码行数:6,代码来源:RandomPointsBuilder.java

示例14: publish

import com.vividsolutions.jts.geom.Envelope; //导入方法依赖的package包/类
public void publish(DmlEvent event) {

		String metadata = extractMetadata(event);
		String changedTableSchema = event.getSchemaName();
		String changedTableName = event.getTableName();
		String type = event.getType().toString();
		Long transactionId = event.getTransactionId();
		PGobject timestamp = getTimestamp(event);
		PGobject oldjson = getJsonOldValues(event);
		PGobject newjson = getJsonNewValues(event);
		
		Object[] params;
		String sql;
		int[] types;
		
		Envelope envelope = event.getEnvelope();
		if (! envelope.isNull()) {
			
			//expand if necessasry
			if (envelope.getHeight() < minSize  && envelope.getWidth() < minSize) {
				envelope.expandBy(bufferSize);
			}
			
			//Transform Bounding Box of the change into WKB
			
			GeometryFactory geomFactory = new GeometryFactory(new PrecisionModel(), epsgCode);
			WKBWriter wkbWriter = new WKBWriter(2, true);
			byte[] wkb = wkbWriter.write(geomFactory.toGeometry(envelope));
			params = new Object[]{wkb, type, changedTableSchema, changedTableName, transactionId, timestamp, metadata, oldjson, newjson};
			types = new int[] {Types.BINARY, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.BIGINT, Types.OTHER, Types.VARCHAR, Types.OTHER, Types.OTHER};
			sql = "INSERT INTO "+schemaname + "." + tableName + "("+regionColumnName
				+", "+transactionTypeColumnName + ", "+schemaColumnName+", "+tableColumnName+", "+txIdColumnName
				+", "+commitTimestampColumnName+", "+metadataColumnName+", "+jsonOldValuesColumnName+", "+jsonNewValuesColumName
				+") VALUES (?,?,?,?,?,?,?,?,?)";
		}
		else {
			//geometry is null, do not include it in SQL insert statement
			params = new Object[]{type, changedTableSchema, changedTableName, transactionId, timestamp, metadata, oldjson, newjson};
			types = new int[] {Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.BIGINT, Types.OTHER, Types.VARCHAR, Types.OTHER, Types.OTHER};
			sql = "INSERT INTO "+schemaname + "." + tableName + "("
					+transactionTypeColumnName + ", "+schemaColumnName+", "+tableColumnName+", "+txIdColumnName
					+", "+commitTimestampColumnName+", "+metadataColumnName+", "+jsonOldValuesColumnName+", "+jsonNewValuesColumName
					+") VALUES (?,?,?,?,?,?,?,?)";
		}
		template.update(sql, params,types);
	}
 
开发者ID:sebastian-r-schmidt,项目名称:logicaldecoding,代码行数:47,代码来源:TrackTablePublisher.java


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