Skip to content

Commit

Permalink
3d vue (#12)
Browse files Browse the repository at this point in the history
* improving 3D vue + adding read of PolylineSetRepresentation

* possibility to use graphical information with HSV color in DiscreteColorMap for etp 3D visualization

* readme
  • Loading branch information
valentin-gauthier-geosiris authored May 25, 2023
1 parent 4301ca4 commit bdf7ff6
Show file tree
Hide file tree
Showing 24 changed files with 1,463 additions and 609 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ The WebStudio is a web application that allows to manipulate energyml file (such
- TriangualtedSetRepresentation
- PolylineSetRepresentation
- PointSetRepresentation
- 1.0.11:
- 3D visu :
- *ColorInformation* in a *GraphicalInformationSet* can be used if it references an **HSV color** in a *DiscreteColorMap*

## License

Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<groupId>com.geosiris</groupId>
<artifactId>webstudio</artifactId>
<name>${project.groupId}:${project.artifactId}</name>
<version>1.0.10</version>
<version>1.0.11</version>
<organization>
<name>Geosiris</name>
<url>http://www.geosiris.com</url>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,14 @@ public Collection<Message> on_GetDataObjectsResponse(GetDataObjectsResponse msg,
filesToImport.add(new String(msg.getDataObjects().get(dr).getData().array(), StandardCharsets.UTF_8));
}
}
String res = FileReciever.loadFiles_Unnamed(session, filesToImport, false, true, true);
if(filesToImport.size() > 0) {
String res = FileReciever.loadFiles_Unnamed(session, filesToImport, false, true, true);

SessionUtility.log(session, new ServerLogMessage(ServerLogMessage.MessageType.LOG, res, SessionUtility.EDITOR_NAME));
SessionUtility.log(session, new ServerLogMessage(ServerLogMessage.MessageType.TOAST,"ETP : " + filesToImport.size()
+ " imported objects. If they not appear in the table view, refresh the page. ",SessionUtility.EDITOR_NAME));
SessionUtility.log(session, new ServerLogMessage(ServerLogMessage.MessageType.ACTION, "reload", SessionUtility.EDITOR_NAME));
SessionUtility.log(session, new ServerLogMessage(ServerLogMessage.MessageType.LOG, res, SessionUtility.EDITOR_NAME));
SessionUtility.log(session, new ServerLogMessage(ServerLogMessage.MessageType.TOAST, "ETP : " + filesToImport.size()
+ " imported objects. If they not appear in the table view, refresh the page. ", SessionUtility.EDITOR_NAME));
SessionUtility.log(session, new ServerLogMessage(ServerLogMessage.MessageType.ACTION, "reload", SessionUtility.EDITOR_NAME));
}
return new ArrayList<>();
}

Expand Down
45 changes: 45 additions & 0 deletions src/main/java/com/geosiris/webstudio/model/ETP3DObject.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
Copyright 2019 GEOSIRIS
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package com.geosiris.webstudio.model;

import com.google.gson.Gson;

public class ETP3DObject {

private String pointColor, lineColor, faceColor;
private String data, fileType;
private String type, uuid, title;

private String epsgCode;

public ETP3DObject(String data, String fileType, String type, String uuid, String title, String pointColor, String lineColor, String faceColor, String epsgCode) {
this.data = data;
this.fileType = fileType;
this.type = type;
this.uuid = uuid;
this.title = title;
this.pointColor = pointColor;
this.lineColor = lineColor;
this.faceColor = faceColor;
this.epsgCode = epsgCode;
}

@Override
public String toString(){
Gson gson = new Gson();
return gson.toJson(this);
}
}
10 changes: 5 additions & 5 deletions src/main/java/com/geosiris/webstudio/servlet/ObjectEdit.java
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ public String editObject(HttpSession session, String rootUUID, String command, S
try {
if (SessionUtility.configIsMoreVerborseThan(ConfigurationType.debug))
logger.debug(p_k_i + ") parameter " + key);
ResqmlObjectControler.modifyResqmlObjectFromParameter(resqmlObj, key,
ResqmlObjectControler.modifyResqmlObjectFromParameter(session, resqmlObj, key,
ModficationType.EDITION, parameterMap.get(key)[p_k_i], map);
if (SessionUtility.configIsMoreVerborseThan(ConfigurationType.debug))
logger.debug(resqmlObj.getClass().getName() + " - "
Expand All @@ -186,7 +186,7 @@ public String editObject(HttpSession session, String rootUUID, String command, S
if (resqmlObj.getClass().getName().toLowerCase().endsWith("activity")
&& key.toLowerCase().endsWith("activitydescriptor")) {
Object activityTemplate = map.get(parameterMap.get(key)[p_k_i]);
ResqmlObjectControler.prefillActivityFromTemplate(activityTemplate, resqmlObj);
ResqmlObjectControler.prefillActivityFromTemplate(session, activityTemplate, resqmlObj);
}
} catch (Exception e) {
logger.error(e.getMessage(), e);
Expand All @@ -199,7 +199,7 @@ public String editObject(HttpSession session, String rootUUID, String command, S
}
response = "Object edited : '" + rootUUID + "'";
try {
ResqmlObjectControler.modifyResqmlObjectFromParameter(resqmlObj, ".Citation.LastUpdate",
ResqmlObjectControler.modifyResqmlObjectFromParameter(session, resqmlObj, ".Citation.LastUpdate",
ModficationType.EDITION, now.toString(), map);
} catch (Exception e) {
logger.error(e.getMessage(), e);
Expand Down Expand Up @@ -259,7 +259,7 @@ public String editObject(HttpSession session, String rootUUID, String command, S
logger.debug("trying copy with schemaVersion '" + copyVersion + "'");
if (resqmlObj != null) {
try {
Object copyObj = ResQMLConverter.getCopy(resqmlObj, map);
Object copyObj = ResQMLConverter.getCopy(session, resqmlObj, map);
String copyUuid = ObjectController.getObjectAttributeValue(copyObj, "Uuid") + "";
if (copyObj != null) {
map.put(copyUuid, copyObj);
Expand All @@ -286,7 +286,7 @@ public String editObject(HttpSession session, String rootUUID, String command, S
try {
if (SessionUtility.configIsMoreVerborseThan(ConfigurationType.debug))
logger.debug("#suppression subpath : " + subPath);
ResqmlObjectControler.modifyResqmlObjectFromParameter(resqmlObj, subPath, ModficationType.EDITION,
ResqmlObjectControler.modifyResqmlObjectFromParameter(session, resqmlObj, subPath, ModficationType.EDITION,
null, map);
// logger.debug("#new object json : " + ObjectTree.createTree(resqmlObj).toJSON());
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response) t
response.setCharacterEncoding("UTF-8");
out.write("File " + filePath + " not found.");
out.flush();

}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,8 @@ public static boolean removeAdditionalFileFromWorkspace(HttpSession session, Str
}catch (Exception e){
logger.error(e.getMessage(), e);
}
}else{
return SessionUtility.removeNotEnergymlObject(session, filePath);
}
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,12 @@
*/
package com.geosiris.webstudio.servlet.energyml;

import Energistics.Etp.v12.Datatypes.Object.Resource;
import com.geosiris.energyml.utils.EPCGenericManager;
import com.geosiris.energyml.utils.ObjectController;
import com.geosiris.etp.utils.ETPUri;
import com.geosiris.webstudio.servlet.Editor;
import com.geosiris.webstudio.utils.ETPUtils;
import com.geosiris.webstudio.utils.SessionUtility;
import com.geosiris.webstudio.utils.Utility;
import jakarta.servlet.ServletException;
Expand All @@ -41,19 +44,19 @@
@WebServlet("/ResqmlAccessibleDOR")
public class ResqmlAccessibleDOR extends HttpServlet {
private static final long serialVersionUID = 1L;
public static Logger logger = LogManager.getLogger(ResqmlAccessibleDOR.class);
public static Logger logger = LogManager.getLogger(ResqmlAccessibleDOR.class);

public static final HashMap<String, List<String>> mapAccessibleDORTypes = Editor.pkgManager.getAccessibleDORTypes();
/**
* @see HttpServlet#HttpServlet()
*/
public ResqmlAccessibleDOR() {
super();
}



/**
* @see HttpServlet#HttpServlet()
*/
public ResqmlAccessibleDOR() {
super();
}


/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
Expand All @@ -62,15 +65,15 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response) t
return;
}
HttpSession session = request.getSession(false);

String uuid = request.getParameter("uuid"); // Get the uuid of the object that want to references a DOR

String subParamPath = request.getParameter("subParamPath"); // Get the uuid of the object that want to references a DOR

String subParamName = request.getParameter("subParamName");

//logger.error("subparam Path : " + subParamPath);
String answer = "{}";
StringBuilder answer = new StringBuilder("{}");
if(uuid!=null) {
Map<String, Object> map = SessionUtility.getResqmlObjects(session);
if(map.containsKey(uuid)) {
Expand All @@ -80,15 +83,47 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response) t
subParam = ObjectController.getObjectAttributeValue(resqmlObj, subParamPath);
}
List<Object> dorable = EPCGenericManager.getAccessibleDORs(resqmlObj, subParam, subParamName, map.values(), mapAccessibleDORTypes);
answer = Utility.getEPCContentAsJSON(dorable);

answer = new StringBuilder("{ \"workspace\": ");
answer.append(Utility.getEPCContentAsJSON(dorable));
answer.append(", \"etp\": [");
try {
String dataspace = request.getParameter("dataspace");
int cpt = 0;
for(Resource r: ETPUtils.getResources(session, dataspace)){
ETPUri uri = ETPUri.parse(r.getUri().toString());
if(!uri.hasDataspace() && dataspace != null && dataspace.length() > 0){
uri.setDataspace(dataspace);
}

answer.append("{ ");
answer.append("\"num\" : \"").append(cpt).append("\", ");
answer.append("\"title\" : \"").append(r.getName()).append("\", ");
answer.append("\"type\" : \"").append(uri.getObjectType()).append("\", ");
answer.append("\"uuid\" : \"").append(uri.getUuid()).append("\", ");
answer.append("\"schemaVersion\" : \"").append(uri.getDomainVersion()).append("\", ");
answer.append("\"package\" : \"").append(uri.getDomain()).append("\", ");
answer.append("\"uri\" : \"").append(uri.toString()).append("\"");
answer.append("},");
cpt++;
}
if(answer.toString().endsWith(",")){
answer.replace(answer.length()-1, answer.length(), "");
}

}catch (Exception e){
logger.error(e);
}
answer.append("]");
answer.append("}");
}
}

PrintWriter out = response.getWriter();
response.setContentType("application/json");
response.setCharacterEncoding("UTF-8");
out.write(answer);
out.flush();
response.setContentType("application/json");
response.setCharacterEncoding("UTF-8");
out.write(answer.toString());
out.flush();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import com.geosiris.etp.utils.ETPUri;
import com.geosiris.etp.websocket.ETPClient;
import com.geosiris.webstudio.logs.ServerLogMessage;
import com.geosiris.webstudio.model.ETP3DObject;
import com.geosiris.webstudio.utils.ETPUtils;
import com.geosiris.webstudio.utils.SessionUtility;
import com.google.gson.Gson;
Expand Down Expand Up @@ -103,12 +104,10 @@ protected void doPost(HttpServletRequest request, HttpServletResponse response)
mapUri.put(mapUri.size()+"", etpuri);
}

ETPClient etpClient = (ETPClient) session.getAttribute(SessionUtility.SESSION_ETP_CLIENT_ID);

List<Map<String, String>> surfaces = new ArrayList<>();
List<ETP3DObject> surfaces = new ArrayList<>();
for(ETPUri etpUri: mapUri.values()) {
try {
surfaces.add( ETPUtils.get3DFileFromETP(etpClient, etpUri.toString(), false));
surfaces.add(ETPUtils.get3DFileFromETP(session, etpUri.toString(), false));
} catch (JAXBException e) {
logger.error(e.getMessage(), e);
}
Expand Down
Loading

0 comments on commit bdf7ff6

Please sign in to comment.