|
From: serega_sh <ser...@gm...> - 2013-02-28 13:44:50
|
Hi, I'm trying to increase perfomance for intersection calculation.
Right now I need to calculate intersection of geometry figures of two sets:
circles and sectors.
It takes 426 seconds to calculate 68.000.000 intersections. It's toooo long.
Here is my code for getting GeometryShapeFactory:
I've used: numPoints=64
PrecisionModel = Fixed, scale=100 (mantissa length==2)
*public final class GeometricShapeFactoryThreadLocalBuilder {
private static final int MANTISSA_LENGTH = 100;
private GeometricShapeFactoryThreadLocalBuilder(){}
public static ThreadLocal<GeometricShapeFactory> buildThreadLocal(){
return new ThreadLocal<GeometricShapeFactory>(){
public GeometricShapeFactory initialValue() {
PrecisionModel fixedPrecisionModel = new
PrecisionModel(MANTISSA_LENGTH);
return new GeometricShapeFactory(new
GeometryFactory(fixedPrecisionModel));
}
};
}
}*
Here is my code to create Geometry figures:
*public final class GeometryBuilder {
private static final int DIAMETER_MULTIPLIER = 2;
private static final int TURN_LEFT = 90; //We should start to roll to
the right from "North"/"Up"/12 o'clock
private static final ThreadLocal<GeometricShapeFactory> SHAPE_FACTORY =
GeometricShapeFactoryThreadLocalBuilder.buildThreadLocal();
private static final Integer DEFAULT_NUM_POINTS = 100;
private GeometryBuilder(){}
private static Circle buildCirlce(GeometryInfo geometryInfo, SpatialCoord
spatialCoordRelativeCenter){
SHAPE_FACTORY.get().setCentre(GeometryUtil.toCoordinate(geometryInfo.getSpatialCoord(),
spatialCoordRelativeCenter));
SHAPE_FACTORY.get().setNumPoints(returnDefaultIfNull(geometryInfo.getNumPoints(),
DEFAULT_NUM_POINTS));
SHAPE_FACTORY.get().setSize(geometryInfo.getRadius().getMeters() *
DIAMETER_MULTIPLIER);
return new Circle(SHAPE_FACTORY.get().createEllipse());
}
private static Sector buildSector(GeometryInfo geometryInfo,
SpatialCoord spatialCoordRelativeCenter){
SHAPE_FACTORY.get().setCentre(GeometryUtil.toCoordinate(geometryInfo.getSpatialCoord(),
spatialCoordRelativeCenter));
SHAPE_FACTORY.get().setNumPoints(returnDefaultIfNull(geometryInfo.getNumPoints(),
DEFAULT_NUM_POINTS));
SHAPE_FACTORY.get().setSize(geometryInfo.getRadius().getMeters() *
DIAMETER_MULTIPLIER);
return new Sector(SHAPE_FACTORY.get()
.createArcPolygon(-toRadians(geometryInfo.getEndAngle().getDegrees() -
TURN_LEFT), toRadians(geometryInfo.getAngleWidth().getDegrees())));
}
}*
Is there any possiblity to significantly increase perfomance?
circles and sectors are presented as polygons described with 64 points. Is
there any way to perfom a hack: use real circles to describe geometry? It's
much cheaper to calculate intersection between cicles/sectors than polygons.
--
View this message in context: http://osgeo-org.1560.n6.nabble.com/Perfomace-problem-while-calculating-intersection-tp5037457.html
Sent from the geotools-gt2-users mailing list archive at Nabble.com.
|