-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Upgrade for PDI 9 - Add write to Geopackage, SVG and GPX - Add read from Geopackage, GPX - Other minor feature Change-Id: I8705fb3fdfe3932beec285b82383f9b70f56e814
- Loading branch information
Showing
312 changed files
with
35,450 additions
and
1,091 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
package com.atolcd.gis.dxf; | ||
|
||
import java.io.IOException; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import com.vividsolutions.jts.geom.Envelope; | ||
|
||
import fr.michaelm.jump.drivers.dxf.DxfENTITY; | ||
import fr.michaelm.jump.drivers.dxf.DxfFile; | ||
import fr.michaelm.jump.drivers.dxf.DxfXDATA; | ||
|
||
public class DXFWriter { | ||
|
||
private String dxfFileName; | ||
private List<Layer> layers; | ||
|
||
public DXFWriter(String fileName) { | ||
|
||
int pointIndex = fileName.lastIndexOf('.'); | ||
if (pointIndex > 0) { | ||
fileName = fileName.substring(0,pointIndex); | ||
} | ||
|
||
this.dxfFileName = fileName.concat(".dxf"); | ||
this.layers = new ArrayList<Layer>(); | ||
|
||
} | ||
|
||
public void addLayer(Layer layer){ | ||
this.layers.add(layer); | ||
} | ||
|
||
public void write(int precision, boolean writeXData) throws IOException{ | ||
|
||
List<String> layerNames = new ArrayList<String>(); | ||
Envelope extent = null; | ||
List<DxfENTITY> entities = new ArrayList<DxfENTITY>(); | ||
|
||
for(Layer layer : this.layers){ | ||
|
||
//Alimente la liste des layers | ||
layerNames.add(layer.getName()); | ||
|
||
//Calcul de l'extent globale | ||
for (Entity entity:layer.getEntities()){ | ||
|
||
if(extent != null){ | ||
extent.expandToInclude(entity.getGeometry().getEnvelopeInternal()); | ||
}else{ | ||
extent = entity.getGeometry().getEnvelopeInternal(); | ||
} | ||
|
||
|
||
//Conversion Entity -> DxfEntity | ||
DxfENTITY dxfENTITY = new DxfENTITY(layer.getName(), entity.getGeometry()); | ||
|
||
for(ExtendedData extendedData : entity.getExtendedData()){ | ||
|
||
int code; | ||
|
||
if(extendedData.getType().equals(String.class)){ | ||
code = DxfXDATA.GROUPCODE_XDATA_STRING; | ||
|
||
}else if(extendedData.getType().equals(Double.class)){ | ||
code = DxfXDATA.GROUPCODE_XDATA_REAL; | ||
|
||
}else if(extendedData.getType().equals(Integer.class)){ | ||
code = DxfXDATA.GROUPCODE_XDATA_INTEGER; | ||
|
||
}else if(extendedData.getType().equals(Long.class)){ | ||
code = DxfXDATA.GROUPCODE_XDATA_LONG; | ||
|
||
}else{ | ||
code = DxfXDATA.GROUPCODE_XDATA_STRING; | ||
} | ||
|
||
dxfENTITY.addXData(new DxfXDATA(extendedData.getName(), code, extendedData.getValue())); | ||
|
||
} | ||
|
||
entities.add(dxfENTITY); | ||
|
||
} | ||
|
||
} | ||
|
||
DxfFile.write(this.dxfFileName, layerNames, extent, entities ,precision, writeXData); | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package com.atolcd.gis.dxf; | ||
|
||
public class ExtendedData { | ||
|
||
private String name; | ||
private Class<?> type; | ||
private Object value; | ||
|
||
public ExtendedData(String name,Class<?> type, Object value) { | ||
this.name = name; | ||
this.type = type; | ||
this.value = value; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
|
||
public Class<?> getType() { | ||
return type; | ||
} | ||
|
||
public void setType(Class<?> type) { | ||
this.type = type; | ||
} | ||
|
||
public Object getValue() { | ||
return value; | ||
} | ||
|
||
public void setValue(Object value) { | ||
this.value = value; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.