Skip to content

Commit

Permalink
hotfix : Change to add attributes when converting pipes, Handling nul…
Browse files Browse the repository at this point in the history
…ls on ASCII conversion failures
  • Loading branch information
znkim committed Aug 30, 2024
1 parent fee1416 commit ae1477c
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 17 deletions.
3 changes: 3 additions & 0 deletions common/src/main/java/com/gaia3d/util/StringUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ public static Optional<String> getExtensionByStringHandling(String filename) {
}

public static String convertUTF8(String ascii) {
if (ascii == null) {
return "";
}
return ascii.chars()
.mapToObj(c -> (char) c)
.map(c -> c < 128 ? c : '_')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import org.joml.Vector3d;

import java.util.List;
import java.util.Map;

@Builder
@Getter
Expand All @@ -15,14 +16,17 @@ public class GaiaPipeLineString {
private String id;
private String name;

private double diameter; // mm
/* only millimeter */
private double diameter;
private float[] rectangularSize;

private GaiaBoundingBox boundingBox;
private PipeType profileType; // 0 = unknown, 1 = circular, 2 = rectangular, 3 = oval, 4 = irregular, etc.
private PipeType profileType;
private String originalFilePath;
private List<Vector3d> positions;

private Map<String, String> properties;

public boolean isSameProfile(GaiaPipeLineString pipeLineString) {
if (profileType != pipeLineString.profileType) {
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,19 @@ protected List<GaiaScene> convert(File file) {
continue;
}

Map<String, String> attributes = new HashMap<>();
FeatureType featureType = feature.getFeatureType();
Collection<PropertyDescriptor> featureDescriptors = featureType.getDescriptors();
AtomicInteger index = new AtomicInteger(0);
featureDescriptors.forEach(attributeDescriptor -> {
Object attribute = feature.getAttribute(index.getAndIncrement());
if (attribute instanceof Geometry) {
return;
}
String attributeString = castStringFromObject(attribute, "null");
attributes.put(attributeDescriptor.getName().getLocalPart(), attributeString);
});

for (LineString lineString : LineStrings) {
Coordinate[] coordinates = lineString.getCoordinates();
List<Vector3d> positions = new ArrayList<>();
Expand Down Expand Up @@ -163,26 +176,12 @@ protected List<GaiaScene> convert(File file) {
.id(feature.getID())
.profileType(PipeType.CIRCULAR)
.diameter(diameter)
.properties(attributes)
.positions(positions).build();
pipeLineString.setOriginalFilePath(file.getPath());
pipeLineStrings.add(pipeLineString);
}


Map<String, String> attributes = new HashMap<>();
FeatureType featureType = feature.getFeatureType();
Collection<PropertyDescriptor> featureDescriptors = featureType.getDescriptors();
AtomicInteger index = new AtomicInteger(0);
featureDescriptors.forEach(attributeDescriptor -> {
Object attribute = feature.getAttribute(index.getAndIncrement());
if (attribute instanceof Geometry) {
return;
}
String attributeString = castStringFromObject(attribute, "null");
//log.debug("{} : {}", attributeDescriptor.getName(), attributeString);
attributes.put(attributeDescriptor.getName().getLocalPart(), attributeString);
});

for (Polygon polygon : polygons) {
if (!polygon.isValid()) {
log.warn("{} Is Invalid Polygon.", feature.getID());
Expand Down Expand Up @@ -370,6 +369,12 @@ private void convertPipeLineStrings(List<GaiaPipeLineString> pipeLineStrings, Li
GaiaNode rootNode = scene.getNodes().get(0);
rootNode.setName("PipeLineStrings");

GaiaAttribute gaiaAttribute = scene.getAttribute();
gaiaAttribute.setAttributes(pipeLineString.getProperties());
Map<String, String> attributes = gaiaAttribute.getAttributes();
gaiaAttribute.setNodeName(rootNode.getName());
attributes.put("name", pipeLineString.getName());

GaiaBoundingBox boundingBox = pipeLineString.getBoundingBox();
Vector3d bboxCenter = boundingBox.getCenter();

Expand Down

0 comments on commit ae1477c

Please sign in to comment.