使用地理工具版本11.2
import java.awt.Rectangle
import com.vividsolutions.jts.geom.Envelope
import org.geotools.coverage.grid.{GeneralGridEnvelope, GridGeometry2D}
import org.geotools.geometry.jts.ReferencedEnvelope
import org.geotools.referencing.crs.DefaultGeographicCRS.WGS84
val minX = -78.523
val minY = 38.010
val maxX = -78.451
val maxY = 38.069
val width = 400
val height = 300
val bounds = new ReferencedEnvelope(new Envelope(minX, maxX, minY, maxY), WGS84)
val rect = new Rectangle(0, 0, width, height)
val ggEnvelope = new GeneralGridEnvelope(rect, bounds.getDimension)
val gm = new GridGeometry2D(ggEnvelope, bounds)
////////////////// This should be [0, 299] but is [-1, 299]//////////////////////////////
gm.worldToGrid(bounds.getLowerCorner)
2条答案
按热度按时间laik7k3q1#
在www.example.com worldToGrid函数的源代码中,可以看到与maxX和minY类似的内容GridGeometry2D.java
wecizke32#
此代码在geotool v29中返回[0,299]