Revision 40419

View differences:

branches/v2_0_0_prep/libraries/libFMap_geometries/src/org/gvsig/fmap/geom/util/Converter.java
115 115
	}
116 116

  
117 117
	/**
118
	 * Receives a JTS Geometry and returns a fmap IGeometry
118
	 * Receives a JTS Geometry and returns a DAL Geometry
119 119
	 * @param jtsGeometry jts Geometry
120 120
	 * @return IGeometry of FMap
121 121
	 * @author azabala
......
174 174

  
175 175
			return shpNew;
176 176
		} catch (NoninvertibleTransformException e) {
177
			// TODO Auto-generated catch block
178 177
			e.printStackTrace();
179 178
		}
180 179

  
......
288 287
		double[] theData = new double[6];
289 288
		ArrayList arrayCoords = null;
290 289
		Coordinate coord;
290
		int subType = shp.getGeometryType().getSubType();
291
		boolean is3D = subType == 1 || subType == 3;
291 292

  
292 293
		arrayLines = new ArrayList();
293
		theIterator = shp.getPathIterator(null, manager.getFlatness());
294
		//El pathIterator no tiene en cuenta coordenadas 3D
295
		//theIterator = pol.getPathIterator(null, manager.getFlatness());
296
		GeneralPathX gp = shp.getGeneralPath();
294 297

  
295
		while (!theIterator.isDone()) {
296
			//while not done
297
			theType = theIterator.currentSegment(theData);
298
		//while (!theIterator.isDone()) {
299
		int numCoords = gp.getNumCoords();
300
		if(gp.isClosed())
301
			numCoords ++;
302
		for (int nPoint = 0; nPoint < numCoords; nPoint++) {
303
			if(nPoint < gp.getNumCoords()) {
304
				theData = gp.getCoordinatesAt(nPoint);
305
			} 
306
			theType = gp.getTypeAt(nPoint);
298 307

  
299 308
			//Populate a segment of the new
300 309
			// GeneralPathX object.
......
305 314
				if (arrayCoords == null) {
306 315
					arrayCoords = new ArrayList();
307 316
				} else {
308
					lin = geomFactory.createLineString(CoordinateArrays.toCoordinateArray(
309
							arrayCoords));
317
					lin = geomFactory.createLineString(
318
							CoordinateArrays.toCoordinateArray(arrayCoords));
310 319
					lin.setSRID(srid);
311 320
					arrayLines.add(lin);
312 321
					arrayCoords = new ArrayList();
313 322
				}
314 323

  
315 324
				numParts++;
316
				coord = new Coordinate(theData[0], theData[1]);
325
				if(is3D)
326
					coord = new Coordinate(theData[0], theData[1], theData[2]);
327
				else
328
					coord = new Coordinate(theData[0], theData[1]);
317 329

  
318 330
				arrayCoords.add(coord);
319

  
320 331
				break;
321 332

  
322 333
			case PathIterator.SEG_LINETO:
323
				arrayCoords.add(new Coordinate(theData[0],
324
						theData[1]));
325

  
334
				if(is3D)
335
					arrayCoords.add(new Coordinate(theData[0], theData[1], theData[2]));
336
				else
337
					arrayCoords.add(new Coordinate(theData[0], theData[1]));
326 338
				break;
327 339

  
328 340
			case PathIterator.SEG_QUADTO:
329 341
				System.out.println("Not supported here");
330

  
331 342
				break;
332 343

  
333 344
			case PathIterator.SEG_CUBICTO:
334 345
				System.out.println("Not supported here");
335

  
336 346
				break;
337 347

  
338 348
			case PathIterator.SEG_CLOSE:
339 349
				Coordinate firstCoord = (Coordinate) arrayCoords.get(0);
340
				arrayCoords.add(new Coordinate(firstCoord.x,
341
						firstCoord.y));
342

  
350
				if(is3D)
351
					arrayCoords.add(new Coordinate(firstCoord.x, firstCoord.y, firstCoord.z));
352
				else
353
					arrayCoords.add(new Coordinate(firstCoord.x, firstCoord.y));
343 354
				break;
344 355
			} //end switch
345 356

  
346
			theIterator.next();
357
			//theIterator.next();
347 358
		} //end while loop
348 359

  
349
		if (arrayCoords.size()<2) {
360
		if (arrayCoords.size() < 2) {
350 361

  
351
		}else{
352

  
353
			lin = new com.vividsolutions.jts.geom.GeometryFactory().createLineString(CoordinateArrays.toCoordinateArray(
354
					arrayCoords));
355

  
362
		} else {
363
			lin = new com.vividsolutions.jts.geom.GeometryFactory().createLineString(
364
					CoordinateArrays.toCoordinateArray(arrayCoords));
356 365
			lin.setSRID(srid);
357

  
358 366
		}
359 367

  
360 368
		return lin;
361 369
	}
362 370

  
363 371
	/**
364
	 * Convierte un FShape a una Geometry del JTS. Para ello, utilizamos un
372
	 * Convierte un Geometry de DAL a una Geometry del JTS. Para ello, utilizamos un
365 373
	 * flattened PathIterator. El flattened indica que las curvas las pasa a
366 374
	 * segmentos de linea recta AUTOMATICAMENTE!!!.
367 375
	 *
......
375 383

  
376 384
		com.vividsolutions.jts.geom.Geometry geoJTS = null;
377 385
		Coordinate coord;
378
		//Coordinate[] coords;
379 386
		ArrayList arrayCoords = null;
380 387
		ArrayList arrayLines;
381 388
		LineString lin;
382
		//LinearRing linRing;
383
		//LinearRing linRingExt = null;
384 389
		int theType;
385 390
		int numParts = 0;
391
		int subType = shp.getGeometryType().getSubType();
392
		boolean is3D = subType == 1 || subType == 3;
386 393

  
387
		//	 	Use this array to store segment coordinate data
394
		//Use this array to store segment coordinate data
388 395
		double[] theData = new double[6];
389 396
		PathIterator theIterator;
390 397

  
391
		//logger.debug(shp.toString());
392 398

  
393

  
394 399
		switch (shapeType) {
395 400
		case Geometry.TYPES.POINT:
396
			org.gvsig.fmap.geom.primitive.impl.Point2D p = (org.gvsig.fmap.geom.primitive.impl.Point2D) shp;
397
			coord = new Coordinate(p.getX(), p.getY());
401
			if(is3D) {
402
				org.gvsig.fmap.geom.primitive.impl.Point2DZ p = (org.gvsig.fmap.geom.primitive.impl.Point2DZ) shp;
403
				coord = new Coordinate(p.getX(), p.getY(), p.getCoordinateAt(Geometry.DIMENSIONS.Z));
404
			} else {
405
				org.gvsig.fmap.geom.primitive.impl.Point2D p = (org.gvsig.fmap.geom.primitive.impl.Point2D) shp;
406
				coord = new Coordinate(p.getX(), p.getY());
407
			}
398 408
			geoJTS = geomFactory.createPoint(coord);
399 409
			geoJTS.setSRID(srid);
400

  
401 410
			break;
402 411

  
403 412
			/*case Geometry.TYPES.MULTIPOINT:
......
417 426
		case Geometry.TYPES.ARC:
418 427
        case Geometry.TYPES.SPLINE:
419 428
			arrayLines = new ArrayList();
420
			theIterator = shp.getPathIterator(null, manager.getFlatness());
429
			//El pathIterator no tiene en cuenta coordenadas 3D
430
			//theIterator = pol.getPathIterator(null, manager.getFlatness());
431
			GeneralPathX gp = shp.getGeneralPath();
421 432

  
422
			while (!theIterator.isDone()) {
423
				//while not done
424
				theType = theIterator.currentSegment(theData);
433
			//while (!theIterator.isDone()) {
434
			int numCoords = gp.getNumCoords();
435
			for (int nPoint = 0; nPoint < numCoords; nPoint++) {
436
				theData = gp.getCoordinatesAt(nPoint);
437
				theType = gp.getTypeAt(nPoint);
425 438

  
426 439
				//Populate a segment of the new
427 440
				// GeneralPathX object.
......
432 445
					if (arrayCoords == null) {
433 446
						arrayCoords = new ArrayList();
434 447
					} else {
435
						lin = geomFactory.createLineString(CoordinateArrays.toCoordinateArray(
436
								arrayCoords));
448
						lin = geomFactory.createLineString(CoordinateArrays.toCoordinateArray(arrayCoords));
437 449
						lin.setSRID(srid);
438 450
						arrayLines.add(lin);
439 451
						arrayCoords = new ArrayList();
440 452
					}
441 453

  
442 454
					numParts++;
443
					coord = new Coordinate(theData[0], theData[1]);
444

  
455
					if(is3D)
456
						coord = new Coordinate(theData[0], theData[1], theData[2]);
457
					else
458
						coord = new Coordinate(theData[0], theData[1]);
459
					
445 460
					arrayCoords.add(coord);
446

  
447 461
					break;
448 462

  
449 463
				case PathIterator.SEG_LINETO:
450
					arrayCoords.add(new Coordinate(theData[0],
451
							theData[1]));
452

  
464
					if(is3D)
465
						arrayCoords.add(new Coordinate(theData[0], theData[1], theData[2]));
466
					else
467
						arrayCoords.add(new Coordinate(theData[0], theData[1]));
453 468
					break;
454 469

  
455 470
				case PathIterator.SEG_QUADTO:
456 471
					System.out.println("Not supported here");
457

  
458 472
					break;
459 473

  
460 474
				case PathIterator.SEG_CUBICTO:
461 475
					System.out.println("Not supported here");
462

  
463 476
					break;
464 477

  
465 478
				case PathIterator.SEG_CLOSE:
466 479
					Coordinate firstCoord = (Coordinate) arrayCoords.get(0);
467
					arrayCoords.add(new Coordinate(firstCoord.x,
468
							firstCoord.y));
469

  
480
					if(is3D)
481
						arrayCoords.add(new Coordinate(firstCoord.x, firstCoord.y, firstCoord.z));
482
					else
483
						arrayCoords.add(new Coordinate(firstCoord.x, firstCoord.y));
470 484
					break;
471 485
				} //end switch
472 486

  
473
				theIterator.next();
487
				//theIterator.next();
474 488
			} //end while loop
475 489

  
476
			if (arrayCoords.size()<2) {
490
			if (arrayCoords.size() < 2) {
477 491
				break;
478 492
			}
479
			lin = new com.vividsolutions.jts.geom.GeometryFactory().createLineString(CoordinateArrays.toCoordinateArray(
480
					arrayCoords));
493
			lin = new com.vividsolutions.jts.geom.GeometryFactory().createLineString(
494
					CoordinateArrays.toCoordinateArray(arrayCoords));
481 495

  
482 496
			lin.setSRID(srid);
483 497
			// CAMBIO: ENTREGAMOS SIEMPRE MULTILINESTRING, QUE ES
484
			// LO QUE HACE TODO EL MUNDO CUANDO ESCRIBE EN POSTGIS
498
			// LO QUE HACE TO_DO EL MUNDO CUANDO ESCRIBE EN POSTGIS
485 499
			// O CON GEOTOOLS
486 500
			// if (numParts > 1) // Generamos una MultiLineString
487 501
			//  {
488 502
			arrayLines.add(lin);
489
			geoJTS = geomFactory.createMultiLineString(com.vividsolutions.jts.geom.GeometryFactory.toLineStringArray(
490
					arrayLines));
503
			geoJTS = geomFactory.createMultiLineString(
504
					com.vividsolutions.jts.geom.GeometryFactory.toLineStringArray(arrayLines));
491 505
			geoJTS.setSRID(srid);
492
			/* } else {
493
			 geoJTS = lin;
494
			 } */
495

  
496 506
			break;
497 507

  
498 508
		case Geometry.TYPES.SURFACE:
......
504 514
			ArrayList holes = new ArrayList();
505 515
			Coordinate[] points = null;
506 516

  
507
			theIterator = shp.getPathIterator(null, manager.getFlatness());
517
			//El pathIterator no tiene en cuenta coordenadas 3D
518
			//theIterator = pol.getPathIterator(null, manager.getFlatness());
519
			GeneralPathX gp1 = shp.getGeneralPath();
508 520

  
509
			while (!theIterator.isDone()) {
510
				//while not done
511
				theType = theIterator.currentSegment(theData);
521
			//while (!theIterator.isDone()) {
522
			for (int nPoint = 0; nPoint < gp1.getNumCoords(); nPoint++) {
523
				theData = gp1.getCoordinatesAt(nPoint);
524
				theType = gp1.getTypeAt(nPoint);
512 525

  
513 526
				//Populate a segment of the new
514 527
				// GeneralPathX object.
......
542 555
							if (same) {
543 556
								return geomFactory.createPoint(points[0]);
544 557
							}
545
							if (points.length>1 && points.length<=3) {
558
							if (points.length>1 && points.length <= 3) {
546 559
								// return geomFactory.createLineString(points);
547 560
								return geomFactory.createMultiLineString(new LineString[] {geomFactory.createLineString(points)});
548 561
							}
......
568 581
					}
569 582

  
570 583
					numParts++;
571
					arrayCoords.add(new Coordinate(theData[0],
572
							theData[1]));
573

  
584
					if(is3D)
585
						arrayCoords.add(new Coordinate(theData[0], theData[1], theData[2]));
586
					else
587
						arrayCoords.add(new Coordinate(theData[0], theData[1]));
574 588
					break;
575 589

  
576 590
				case PathIterator.SEG_LINETO:
577
					arrayCoords.add(new Coordinate(theData[0],
578
							theData[1]));
579

  
591
					if(is3D)
592
						arrayCoords.add(new Coordinate(theData[0], theData[1], theData[2]));
593
					else
594
						arrayCoords.add(new Coordinate(theData[0], theData[1]));
580 595
					break;
581 596

  
582 597
				case PathIterator.SEG_QUADTO:
......
586 601

  
587 602
				case PathIterator.SEG_CUBICTO:
588 603
					System.out.println("SEG_CUBICTO Not supported here");
589

  
590 604
					break;
591 605

  
592 606
				case PathIterator.SEG_CLOSE:
593 607
					Coordinate firstCoord = (Coordinate) arrayCoords.get(0);
594
					arrayCoords.add(new Coordinate(firstCoord.x,
595
							firstCoord.y));
596

  
608
					if(is3D)
609
						arrayCoords.add(new Coordinate(firstCoord.x, firstCoord.y, firstCoord.z));
610
					else
611
						arrayCoords.add(new Coordinate(firstCoord.x, firstCoord.y));
597 612
					break;
598 613
				} //end switch
599 614

  
600
				// System.out.println("theData[0] = " + theData[0] + " theData[1]=" + theData[1]);
601
				theIterator.next();
615
				//theIterator.next();
602 616
			} //end while loop
603 617

  
604 618

  
605 619
			Coordinate firstCoord = (Coordinate) arrayCoords.get(0);
606
			Coordinate lastCoord = (Coordinate) arrayCoords.get(arrayCoords
607
					.size() - 1);
620
			Coordinate lastCoord = (Coordinate) arrayCoords.get(arrayCoords.size() - 1);
608 621
			if (!isClosed(firstCoord, lastCoord)) {
609 622
				arrayCoords.add(firstCoord);
610 623
			}
......
638 651
				 * caso cuando es una linea de 3 puntos, no creo un LinearRing, sino
639 652
				 * una linea
640 653
				 */
641
				if (points.length>1 && points.length<=3) {
654
				if (points.length > 1 && points.length <= 3) {
642 655
					// return geomFactory.createLineString(points);
643
					geoJTS = geomFactory
644
					.createMultiLineString(new LineString[] { geomFactory
645
							.createLineString(points) });
656
					geoJTS = geomFactory.createMultiLineString(new LineString[] { geomFactory.createLineString(points) });
646 657
					geoJTS.setSRID(srid);
647 658
					return geoJTS;
648 659
				}
649
				System.err.println(
650
				"Caught Topology exception in GMLLinearRingHandler");
660
				System.err.println("Caught Topology exception in GMLLinearRingHandler");
651 661

  
652 662
				return null;
653 663
			}
......
721 731
			Polygon[] polygons = new Polygon[shells.size()];
722 732

  
723 733
			for (int i = 0; i < shells.size(); i++) {
724
				polygons[i] = geomFactory.createPolygon((LinearRing) shells.get(
725
						i),
726
						(LinearRing[]) ((ArrayList) holesForShells.get(i)).toArray(
727
								new LinearRing[0]));
734
				polygons[i] = geomFactory.createPolygon(
735
						(LinearRing) shells.get(i),
736
						(LinearRing[]) ((ArrayList) holesForShells.get(i)).toArray(new LinearRing[0]));
728 737
				polygons[i].setSRID(srid);
729 738
			}
730 739
			// CAMBIO: ENTREGAMOS SIEMPRE MULTILINESTRING, QUE ES
731
			// LO QUE HACE TODO EL MUNDO CUANDO ESCRIBE EN POSTGIS
740
			// LO QUE HACE TO_DO EL MUNDO CUANDO ESCRIBE EN POSTGIS
732 741
			// O CON GEOTOOLS
733 742
			// if (numParts > 1) // Generamos una MultiLineString
734 743

  
......
769 778
			geoJTS = multiSurfaceToJts((MultiSurface)shp, srid);
770 779
			geoJTS.setSRID(srid);
771 780
			break;
772

  
773 781
		}
774 782

  
775 783
		geoJTS.setSRID(srid);
......
777 785
	}
778 786

  
779 787
	/**
780
	 * Converts JTS Geometry objects into Java 2D Shape objects
781
	 *
782
	 * @param geo Geometry de JTS.
783
	 *
784
	 * @return FShape.
785
	 */
786
	//	public static FShape jts_to_java2d(com.vividsolutions.jts.geom.Geometry geo) {
787
	//		FShape shpNew = null;
788
	//
789
	//		try {
790
	//			if (geo instanceof Point) {
791
	//				shpNew = new org.gvsig.fmap.geom.primitive.Point2D(null, null, ((Point) geo).getX(), ((Point) geo).getY());
792
	//			}
793
	//
794
	//			if (geo.isEmpty()) {
795
	//				shpNew = null;
796
	//			}
797
	//
798
	//			if (geo instanceof Polygon) {
799
	//				shpNew = new Surface2D(null, null, toShape((Polygon) geo));
800
	//			}
801
	//
802
	//			if (geo instanceof MultiPolygon) {
803
	//				shpNew = new Surface2D(null, null, toShape((MultiPolygon) geo));
804
	//			}
805
	//
806
	//			if (geo instanceof LineString) {
807
	//				shpNew = new Curve2D(null, null, toShape((LineString) geo));
808
	//			}
809
	//
810
	//			if (geo instanceof MultiLineString) {
811
	//				shpNew = new Curve2D(null, null, toShape((MultiLineString) geo));
812
	//			}
813
	//
814
	//			return shpNew;
815
	//		} catch (NoninvertibleTransformException e) {
816
	//			// TODO Auto-generated catch block
817
	//			e.printStackTrace();
818
	//		}
819
	//
820
	//		return null;
821
	//	}
822

  
823
	/**
824 788
	 * DOCUMENT ME!
825 789
	 *
826 790
	 * @param p DOCUMENT ME!
......
1277 1241
		int theType;
1278 1242
		int numParts = 0;
1279 1243

  
1280
		//	 	Use this array to store segment coordinate data
1281
		double[] theData = new double[6];
1282
		PathIterator theIterator;
1244
		//Use this array to store segment coordinate data
1245
		double[] theData = new double[4];
1283 1246

  
1284 1247
		ArrayList shells = new ArrayList();
1285 1248
		ArrayList holes = new ArrayList();
1286 1249
		Coordinate[] points = null;
1250
		
1251
		int subType = pol.getGeometryType().getSubType();
1252
		boolean is3D = subType == 1 || subType == 3;
1253
		
1254
		//El pathIterator no tiene en cuenta coordenadas 3D
1255
		//theIterator = pol.getPathIterator(null, manager.getFlatness());
1256
		GeneralPathX gp = pol.getGeneralPath();
1287 1257

  
1288
		theIterator = pol.getPathIterator(null, manager.getFlatness());
1258
		//while (!theIterator.isDone()) {
1259
		for (int nPoint = 0; nPoint < gp.getNumCoords(); nPoint++) {
1260
			theData = gp.getCoordinatesAt(nPoint);
1261
			theType = gp.getTypeAt(nPoint);
1289 1262

  
1290
		while (!theIterator.isDone()) {
1291
			//while not done
1292
			theType = theIterator.currentSegment(theData);
1293

  
1294 1263
			//Populate a segment of the new
1295 1264
			// GeneralPathX object.
1296 1265
			//Process the current segment to populate a new
......
1313 1282
							shells.add(ring);
1314 1283
						}
1315 1284
					} catch (Exception e) {
1316
						System.err.println(
1317
								"Caught Topology exception in GMLLinearRingHandler");
1285
						System.err.println("Caught Topology exception in GMLLinearRingHandler");
1318 1286

  
1319 1287
						return null;
1320 1288
					}
......
1322 1290
				}
1323 1291

  
1324 1292
				numParts++;
1325
				arrayCoords.add(new Coordinate(theData[0],
1326
						theData[1]));
1293
				if(is3D)
1294
					arrayCoords.add(new Coordinate(theData[0], theData[1], theData[2]));
1295
				else
1296
					arrayCoords.add(new Coordinate(theData[0], theData[1]));
1327 1297

  
1328 1298
				break;
1329 1299

  
1330 1300
			case PathIterator.SEG_LINETO:
1331
				arrayCoords.add(new Coordinate(theData[0],
1332
						theData[1]));
1301
				if(is3D)
1302
					arrayCoords.add(new Coordinate(theData[0], theData[1], theData[2]));
1303
				else
1304
					arrayCoords.add(new Coordinate(theData[0], theData[1]));
1333 1305
				break;
1334 1306
			case PathIterator.SEG_QUADTO:
1335 1307
				System.out.println("SEG_QUADTO Not supported here");
......
1339 1311
				break;
1340 1312
			case PathIterator.SEG_CLOSE:
1341 1313
				Coordinate firstCoord = (Coordinate) arrayCoords.get(0);
1342
				arrayCoords.add(new Coordinate(firstCoord.x,
1343
						firstCoord.y));
1314
				if(is3D)
1315
					arrayCoords.add(new Coordinate(firstCoord.x, firstCoord.y, firstCoord.z));
1316
				else
1317
					arrayCoords.add(new Coordinate(firstCoord.x, firstCoord.y));
1344 1318
				break;
1345 1319
			} //end switch
1346 1320

  
1347
			// System.out.println("theData[0] = " + theData[0] + " theData[1]=" + theData[1]);
1348
			theIterator.next();
1321
			//theIterator.next();
1349 1322
		} //end while loop
1350 1323

  
1351 1324
		arrayCoords.add(arrayCoords.get(0));
......
1376 1349
	
1377 1350
	private static com.vividsolutions.jts.geom.Geometry surfaceToJts(Geometry shp, int srid) {
1378 1351
		com.vividsolutions.jts.geom.Geometry geoJTS = null;
1379
		ArrayList arrayLines;
1380
		LineString lin = null;
1381 1352
		PathIterator theIterator;
1382 1353
		int theType;
1383 1354
		int numParts = 0;
1384
		double[] theData = new double[6];
1355
		double[] theData = new double[4];
1385 1356
		ArrayList arrayCoords = null;
1386
		Coordinate coord;
1357
		int subType = shp.getGeometryType().getSubType();
1358
		boolean is3D = subType == 1 || subType == 3;
1387 1359

  
1388
		arrayLines = new ArrayList();
1389 1360

  
1390 1361
		ArrayList shells = new ArrayList();
1391 1362
		ArrayList holes = new ArrayList();
1392 1363
		Coordinate[] points = null;
1364
		
1365
		//El pathIterator no tiene en cuenta coordenadas 3D
1366
		//theIterator = shp.getPathIterator(null, manager.getFlatness());
1367
		GeneralPathX gp = shp.getGeneralPath();
1393 1368

  
1394
		theIterator = shp.getPathIterator(null, manager.getFlatness());
1369
		//while (!theIterator.isDone()) {
1370
		for (int nPoint = 0; nPoint < gp.getNumCoords(); nPoint++) {
1371
			theData = gp.getCoordinatesAt(nPoint);
1372
			theType = gp.getTypeAt(nPoint);
1373
			//theType = theIterator.currentSegment(theData);
1395 1374

  
1396
		while (!theIterator.isDone()) {
1397
			//while not done
1398
			theType = theIterator.currentSegment(theData);
1399

  
1400 1375
			//Populate a segment of the new
1401 1376
			// GeneralPathX object.
1402 1377
			//Process the current segment to populate a new
......
1432 1407
							return geomFactory.createPoint(points[0]);
1433 1408
						}
1434 1409

  
1435
						if (points.length>1 && points.length<=3) {
1410
						if (points.length > 1 && points.length <= 3) {
1436 1411
							// return geomFactory.createLineString(points);
1437 1412
							return geomFactory.createMultiLineString(new LineString[] {geomFactory.createLineString(points)});
1438 1413
						}
......
1458 1433
				}
1459 1434

  
1460 1435
				numParts++;
1461
				arrayCoords.add(new Coordinate(theData[0],
1462
						theData[1]));
1463

  
1436
				if(is3D)
1437
					arrayCoords.add(new Coordinate(theData[0], theData[1], theData[2]));
1438
				else
1439
					arrayCoords.add(new Coordinate(theData[0], theData[1]));
1464 1440
				break;
1465 1441

  
1466 1442
			case PathIterator.SEG_LINETO:
1467

  
1468
				arrayCoords.add(new Coordinate(theData[0],
1469
						theData[1]));
1470

  
1443
				if(is3D)
1444
					arrayCoords.add(new Coordinate(theData[0], theData[1], theData[2]));
1445
				else
1446
					arrayCoords.add(new Coordinate(theData[0], theData[1]));
1471 1447
				break;
1472 1448

  
1473 1449
			case PathIterator.SEG_QUADTO:
1474 1450
				System.out.println("SEG_QUADTO Not supported here");
1475

  
1476 1451
				break;
1477 1452

  
1478 1453
			case PathIterator.SEG_CUBICTO:
1479 1454
				System.out.println("SEG_CUBICTO Not supported here");
1480

  
1481 1455
				break;
1482 1456

  
1483 1457
			case PathIterator.SEG_CLOSE:
1484 1458
				Coordinate firstCoord = (Coordinate) arrayCoords.get(0);
1485
				arrayCoords.add(new Coordinate(firstCoord.x,
1486
						firstCoord.y));
1459
				if(is3D)
1460
					arrayCoords.add(new Coordinate(firstCoord.x, firstCoord.y, firstCoord.z));
1461
				else
1462
					arrayCoords.add(new Coordinate(firstCoord.x, firstCoord.y));
1487 1463

  
1488 1464
				break;
1489 1465
			} //end switch
1490 1466

  
1491 1467
			// System.out.println("theData[0] = " + theData[0] + " theData[1]=" + theData[1]);
1492
			theIterator.next();
1468
			//theIterator.next();
1493 1469
		} //end while loop
1494 1470

  
1495 1471

  
1496 1472
		Coordinate firstCoord = (Coordinate) arrayCoords.get(0);
1497
		Coordinate lastCoord = (Coordinate) arrayCoords.get(arrayCoords
1498
				.size() - 1);
1473
		Coordinate lastCoord = (Coordinate) arrayCoords.get(arrayCoords.size() - 1);
1474
		
1499 1475
		if (!isClosed(firstCoord, lastCoord)) {
1500 1476
			arrayCoords.add(firstCoord);
1501 1477
		}
......
1525 1501
				geoJTS.setSRID(srid);
1526 1502
				return geoJTS;
1527 1503
			}
1528
			if (points.length>1 && points.length<=3) {
1504
			if (points.length > 1 && points.length <= 3) {
1529 1505
				// return geomFactory.createLineString(points);
1530 1506
				geoJTS = geomFactory
1531 1507
				.createMultiLineString(new LineString[] { geomFactory
......
1608 1584
		Polygon[] polygons = new Polygon[shells.size()];
1609 1585

  
1610 1586
		for (int i = 0; i < shells.size(); i++) {
1611
			polygons[i] = geomFactory.createPolygon((LinearRing) shells.get(
1612
					i),
1613
					(LinearRing[]) ((ArrayList) holesForShells.get(i)).toArray(
1614
							new LinearRing[0]));
1587
			polygons[i] = geomFactory.createPolygon(
1588
					(LinearRing) shells.get(i),
1589
					(LinearRing[]) ((ArrayList) holesForShells.get(i)).toArray(new LinearRing[0]));
1615 1590
			polygons[i].setSRID(srid);
1616 1591
		}
1617 1592
		
......
1626 1601
		return geoJTS;
1627 1602
	}
1628 1603

  
1629
	/* public static GeometryCollection convertFGeometryCollection(FGeometryCollection fGeomC)
1630
    {
1631

  
1632
        geomFactory.createGeometryCollection(theGeoms);
1633
    } */
1634 1604
}

Also available in: Unified diff