Skip to content

Commit

Permalink
bugfix when NAN is given in an etp data array
Browse files Browse the repository at this point in the history
  • Loading branch information
valentin-gauthier-geosiris committed Nov 4, 2024
1 parent f51685d commit 86b1b62
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 37 deletions.
14 changes: 13 additions & 1 deletion src/main/java/com/geosiris/webstudio/etp/ETPWorkspace.java
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,17 @@ public List<?> readExternalArray(Object energymlArray, Object rootObj, String pa
.lines()
.collect(Collectors.joining("\n"));
res = gson.fromJson(content, ArrayList.class);

// Following line to remove "NAN" values
res = res.stream().map(x -> x instanceof String ? Double.NaN: x).collect(Collectors.toList());
// if(!res.isEmpty() && res.get(0) instanceof String) {
// try {
// Float.parseFloat((String) res.get(0));
// res = res.stream().map(x -> Float.parseFloat((String) x)).collect(Collectors.toList());
// }catch (Exception ignore){}
// }
logger.info(String.valueOf(res));
logger.info("==> " + res.get(0) + " " + res.get(0).getClass());
return res;
} catch (Exception _ignore) {
_ignore.printStackTrace();
Expand Down Expand Up @@ -215,7 +225,9 @@ public static ETPUri getUriFromObject(Object obj, String dataspace){
uri.setDomain(epc_pkg.getDomain());
uri.setDomainVersion(epc_pkg.getVersionNum().replace(".", "").substring(0,2));
uri.setObjectType(getObjectTypeForFilePath_fromClassName(obj.getClass().getName()));
uri.setVersion((String) ObjectController.getObjectAttributeValue(obj, "version"));
try {
uri.setVersion((String) ObjectController.getObjectAttributeValue(obj, "version"));
}catch (Exception ignore){}
return uri;
}

Expand Down
3 changes: 3 additions & 0 deletions src/main/webapp/ressources/css/epcView.css
Original file line number Diff line number Diff line change
Expand Up @@ -666,6 +666,9 @@ label + input {
}
.modal-xl-customGeosiris .tab-content{
padding-top: 10px;

padding-left: 5px;
padding-right: 5px;
}

.modal-xl{
Expand Down
32 changes: 18 additions & 14 deletions src/main/webapp/ressources/css/splitStyle.css
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,34 @@
background-color: #ccc;
background-repeat: no-repeat;
background-position: 50%;
/*height : 100%;
/*border:2px solid #000;*/
/* outline: 2px solid #000;
outline-offset: -8px; */
position: relative;

border: 1px solid #212529;
margin: 3px;
padding: 6px;
border-radius: 8px;
}

.gutter.gutter-horizontal {
cursor: col-resize;
/* background-image: url("ressources/img/ellipsis-v.png"); */
background-image: url("ressources/img/rectangle-v.png");
background-size: 10px 40px;
border : 1px solid #212529;
/*border-left : 1px solid #212529;*/
/*border-right: 1px solid #212529;*/
background-size: 5px 100px;
width: 8px !important;
height: calc(100% - 30px) !important;
top: 50%;
-ms-transform: translateY(-50%);
transform: translateY(-50%);
}

.gutter.gutter-vertical {
cursor: row-resize;
/* background-image: url("ressources/img/ellipsis-h.png"); */
background-image: url("ressources/img/rectangle-h.png");
background-size: 40px 10px;
/*transform: rotate(90deg);*/
border-top : 1px solid #212529;
border-bottom: 1px solid #212529;
background-size: 100px 5px;
height: 8px !important;
width: calc(100% - 30px) !important;
left: 50%;
-ms-transform: translateX(-50%);
transform: translateX(-50%);
}

.split.split-horizontal, .gutter.gutter-horizontal {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,31 +35,39 @@ export class OffLoader extends SurfaceLoader{

for(var lineIdx = 0; lineIdx < fileContentArray.length-1; lineIdx++){
var line = fileContentArray[lineIdx];
if(line.length > 0){
if(!sizeFound){
var sizesMatch = __XYZ_POINT_REGEXP__.exec(line);
if(sizesMatch != null){
sizeFound = true;
// console.log(sizeFound)
nbPoints = sizesMatch.groups["x"];
}
}else{
var matchPoints = __XYZ_POINT_REGEXP__.exec(line);
// TODO : ça marche pas pour les points !
if(!(pointsFinished) && matchPoints != null && nbPoints > this.points.length){
pointsStart = true;
this.points.push([parseFloat(matchPoints.groups["x"]), parseFloat(matchPoints.groups["y"]), parseFloat(matchPoints.groups["z"])]);
}else if(pointsStart) {
var integers = [...line.matchAll("\\d+")].flat();
var nbFacePoint = Number(integers[0]);
this.trianglesIdx.push(integers.slice(1).map(i => parseInt(i)));
try{
if(line.length > 0){
if(!sizeFound){
var sizesMatch = __XYZ_POINT_REGEXP__.exec(line);
if(sizesMatch != null){
sizeFound = true;
// console.log(sizeFound)
nbPoints = sizesMatch.groups["x"];
}
}else{
/*console.log("===");
console.log("|"+line+"|");
console.log(matchPoints);
console.log("===");*/
var matchPoints = __XYZ_POINT_REGEXP__.exec(line);
// TODO : ça marche pas pour les points !
if(!(pointsFinished) && matchPoints != null && nbPoints > this.points.length){
pointsStart = true;
this.points.push([parseFloat(matchPoints.groups["x"]), parseFloat(matchPoints.groups["y"]), parseFloat(matchPoints.groups["z"])]);
}else if(pointsStart) {
var integers = [...line.matchAll("\\d+")].flat();
if(integers.length > 0){ // TO avoid adding empty value if no match
var nbFacePoint = Number(integers[0]);
this.trianglesIdx.push(integers.slice(1).map(i => parseInt(i)));
}
}else{
/*console.log("===");
console.log("|"+line+"|");
console.log(matchPoints);
console.log("===");*/
}
}
}
}catch(exception){
console.log(fileContent);
console.log(exception);
throw exception;
}
}
/*console.log(this.points);
Expand Down
25 changes: 25 additions & 0 deletions src/main/webapp/ressources/script/modules/UI/modals/etp.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {refreshHighlightedOpenedObjects} from "../ui.js";
import {REGEX_ETP_URI, __ENUM_CONSOLE_MSG_SEVERITY_TOAST__, __ID_CONSOLE__, __RWS_CLIENT_NAME__, CLASS_TABLE_FIXED} from "../../common/variables.js";
import {removeListDuplicatesByObjectKey, getAttribute} from "../../common/utils.js";
import {geo3DVue, openResqmlObjectContentByUUID} from "../../main.js";
import {createToast} from "../snackbar.js";


var ETP_REQUEST_LAUNCH = 0
Expand Down Expand Up @@ -159,6 +160,7 @@ export function loadUrisIn3DVue(){

if(checkedUris != null && checkedUris.length > 0){
importObjectIn3DView(checkedUris).then(fileContent => {
var loadedSurfaces = [];
try{
var jsonValueList = JSON.parse(fileContent);
console.log("3D vue is Loading " + jsonValueList.length + " entities");
Expand All @@ -178,6 +180,7 @@ export function loadUrisIn3DVue(){
obj["faceColor"],
obj["epsgCode"]
);
loadedSurfaces.push(obj["title"] + " : " + obj["uuid"]);
}catch(exception){
console.log(fileContent);
console.log(exception);
Expand All @@ -188,9 +191,31 @@ export function loadUrisIn3DVue(){
});
}
});
if(loadedSurfaces.length > 0){
createToast({
title: "Mesh loader",
time: (new Date(Date.now())).toLocaleTimeString('en-US'),
body: "Loaded surfaces : " + loadedSurfaces.map(x => "<br/>- " + x),
option: {
animation: true,
autohide: true,
delay: 10000
}
})
}
}catch(exception){
console.log(fileContent);
console.log(exception);
createToast({
title: "Mesh loader",
time: (new Date(Date.now())).toLocaleTimeString('en-US'),
body: "Failed to import 3D surface : " + exception,
option: {
animation: true,
autohide: true,
delay: 10000
}
});
}
}).catch((error) => console.error(error));
}
Expand Down

0 comments on commit 86b1b62

Please sign in to comment.