test_class.declarator: DOUBLE_TOLERANCE = .0000000001
test_class.modifier: private static final
test_class.original_string: private static final double DOUBLE_TOLERANCE = .0000000001;
test_class.type: double
test_class.var_name: DOUBLE_TOLERANCE
test_class.declarator: dispatcher
test_class.modifier: @Autowired
  	private
test_class.original_string: @Autowired
  	private CommandDispatcher dispatcher;
test_class.type: CommandDispatcher
test_class.var_name: dispatcher
test_class.declarator: geoService
test_class.modifier: @Autowired
  	private
test_class.original_string: @Autowired
  	private GeoService geoService;
test_class.type: GeoService
test_class.var_name: geoService
test_class.declarator: dtoConverter
test_class.modifier: @Autowired
  	private
test_class.original_string: @Autowired
  	private DtoConverterService dtoConverter;
test_class.type: DtoConverterService
test_class.var_name: dtoConverter
test_class.file: command/src/test/java/org/geomajas/command/geometry/SplitPolygonCommandTest.java
test_class.identifier: SplitPolygonCommandTest
test_case.body: @Test
  	public void testSplitPolygon() throws Exception {
  		SplitPolygonRequest request = new SplitPolygonRequest();
  		GeometryFactory factory = new GeometryFactory();
  		request.setGeometry(
  				dtoConverter.toDto(geoService.createCircle(factory.createPoint(new Coordinate(0, 0)), 10, 10)));
  		request.setSplitter(
  				dtoConverter.toDto(factory.createLineString(new Coordinate[] {
  						new Coordinate(-10, -10), new Coordinate(10, 10)
  				})));
  		SplitPolygonResponse response = (SplitPolygonResponse) dispatcher.execute(
  				SplitPolygonRequest.COMMAND, request, null, "en");
  		if (response.isError()) {
  			response.getErrors().get(0).printStackTrace();
  		}
  		Assert.assertFalse(response.isError());
  		Assert.assertNotNull(response.getGeometries());
  		// @todo should verify that split is correct
  	}
test_case.class_method_signature: SplitPolygonCommandTest.testSplitPolygon()
test_case.full_signature: @Test public void testSplitPolygon()
test_case.identifier: testSplitPolygon
test_case.invocations: setGeometry toDto createCircle createPoint setSplitter toDto createLineString execute isError printStackTrace get getErrors assertFalse isError assertNotNull getGeometries
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testSplitPolygon()
focal_class.declarator: converter
focal_class.modifier: @Autowired
  	private
focal_class.original_string: @Autowired
  	private DtoConverterService converter;
focal_class.type: DtoConverterService
focal_class.var_name: converter
focal_class.file: command/src/main/java/org/geomajas/command/geometry/SplitPolygonCommand.java
focal_class.identifier: SplitPolygonCommand
focal_class.interfaces: implements CommandHasRequest<SplitPolygonRequest, SplitPolygonResponse>
focal_class.class_method_signature: SplitPolygonCommand.getEmptyCommandRequest()
focal_class.full_signature: @Override public SplitPolygonRequest getEmptyCommandRequest()
focal_class.identifier: getEmptyCommandRequest
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: SplitPolygonRequest
focal_class.signature: SplitPolygonRequest getEmptyCommandRequest()
focal_class.class_method_signature: SplitPolygonCommand.getEmptyCommandResponse()
focal_class.full_signature: @Override public SplitPolygonResponse getEmptyCommandResponse()
focal_class.identifier: getEmptyCommandResponse
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: SplitPolygonResponse
focal_class.signature: SplitPolygonResponse getEmptyCommandResponse()
focal_class.class_method_signature: SplitPolygonCommand.execute(SplitPolygonRequest request, SplitPolygonResponse response)
focal_class.full_signature: @Override public void execute(SplitPolygonRequest request, SplitPolygonResponse response)
focal_class.identifier: execute
focal_class.modifiers: @Override public
focal_class.parameters: (SplitPolygonRequest request, SplitPolygonResponse response)
focal_class.return: void
focal_class.signature: void execute(SplitPolygonRequest request, SplitPolygonResponse response)
focal_method.body: @Override
  	public void execute(SplitPolygonRequest request, SplitPolygonResponse response) throws Exception {
  		// convert to most accurate precision model
  		com.vividsolutions.jts.geom.Geometry jtsGeometry = converter.toInternal(request.getGeometry());
  		if (!(jtsGeometry instanceof Polygon)) {
  			throw new GeomajasException(ExceptionCode.UNEXPECTED_PROBLEM, "geometry has to be a Polygon");
  		}
  		Polygon polygon = (Polygon) converter.toInternal(request.getGeometry());
  
  		// Convert to the polygons precision model:
  		jtsGeometry = converter.toInternal(request.getSplitter());
  		if (!(jtsGeometry instanceof LineString)) {
  			throw new GeomajasException(ExceptionCode.UNEXPECTED_PROBLEM, "splitter has to be a LineString");
  		}
  		LineString preciseLine = (LineString) jtsGeometry;
  		int precision = polygon.getPrecisionModel().getMaximumSignificantDigits() - 1;
  		com.vividsolutions.jts.geom.Geometry bufferedLine = preciseLine.buffer(Math.pow(10.0, -precision));
  		com.vividsolutions.jts.geom.Geometry diff = polygon.difference(bufferedLine);
  
  		if (diff instanceof Polygon) {
  			response.setGeometries(new Geometry[] { converter.toDto(diff) });
  		} else if (diff instanceof MultiPolygon) {
  			Geometry[] polygons = new Geometry[diff.getNumGeometries()];
  			for (int i = 0; i < diff.getNumGeometries(); i++) {
  				polygons[i] = converter.toDto(diff.getGeometryN(i));
  			}
  			response.setGeometries(polygons);
  		}
  	}
focal_method.class_method_signature: SplitPolygonCommand.execute(SplitPolygonRequest request, SplitPolygonResponse response)
focal_method.full_signature: @Override public void execute(SplitPolygonRequest request, SplitPolygonResponse response)
focal_method.identifier: execute
focal_method.invocations: toInternal getGeometry toInternal getGeometry toInternal getSplitter getMaximumSignificantDigits getPrecisionModel buffer pow difference setGeometries toDto getNumGeometries getNumGeometries toDto getGeometryN setGeometries
focal_method.modifiers: @Override public
focal_method.parameters: (SplitPolygonRequest request, SplitPolygonResponse response)
focal_method.return: void
focal_method.signature: void execute(SplitPolygonRequest request, SplitPolygonResponse response)