|
From: yy <yon...@so...> - 2004-06-14 18:30:46
|
dear all,
I want to develop some GIS functions in the Repast frame. When I try to =
display multilinestring in GisDisplay, I find one bug in the class of =
uchicago.src.sim.gis.LineStringAdapter.(It seems there is no =
MultiLineStringAdapter in the gis package)
the bug is in the function of setGeometry(Geometry geo).
the code is as following:
*************************************************************************=
*******************************************************************
public void setGeometry(Geometry geo){
if(!geo.getGeometryType().toLowerCase().equals("linestring") &&
=
!(geo.getGeometryType().toLowerCase().equals("multilinestring"))){
throw new IllegalArgumentException("This is not a =
linestring, it is a " + geo.getGeometryType());
}
if(geo.getGeometryType().toLowerCase().startsWith("multi")){
multi =3D true;
}
LineString line =3D (LineString) geo;
super.setFrom(new PointAdapter(line.getStartPoint()));
super.setTo(new PointAdapter(line.getEndPoint()));
Coordinate[] coords =3D line.getCoordinates();
points =3D new LinePoint[coords.length];
points[0] =3D new LinePoint(coords[0]);
points[0].setToPoint(points[1]);
if (points.length < 3) {
points[1] =3D new LinePoint(coords[1]);
points[1].setFromPoint(points[0]);
strength +=3D GisUtilities.getDistance(coords[0], =
coords[1]);
} else {
for (int i =3D 1; i < coords.length - 1; i++) {
points[i] =3D new LinePoint(coords[i]);
strength +=3D GisUtilities.getDistance(coords[i], =
coords[i - 1]);
points[i].setFromPoint(points[i - 1]);
points[i].setToPoint(points[i + 1]);
}
points[points.length - 1] =3D new =
LinePoint(coords[points.length - 1]);
points[points.length - 1].setFromPoint(points[points.length =
- 2]);
strength +=3D GisUtilities.getDistance(coords[points.length =
- 1], coords[points.length - 2]);
}
}
*************************************************************************=
*************************************************************************=
******
at first, this code judge if this geometry is a linestring or =
multilingstring or even neither, if this is a multiline, the multi sign =
will be set to be true, all these are right.
but then it try to force the geo to be a lineString without any =
judgement. When I use this function, my geo is a multiLineString, so =
there will be Exception thrown.
This error are so obvious that I donot sure if this can be called a bug. =
thank you very much!
cheers,
Yong |