Commit ff6aa7e9 authored by PONCELET's avatar PONCELET
Browse files

update python code generator and XSF model

parent e6fb3682
......@@ -59,8 +59,6 @@
"obligation": "M",
"comment": "A short phrase or sentence describing the dataset. For direct sonar-generated files, this can be as simple as \"Files generated by the XYZ sonar\"."
},
{
"name": "xsf_convention_version",
"obligation": "M",
......@@ -68,10 +66,6 @@
"type": "string",
"value": "0.1"
}
],
"variables": [
{
......@@ -91,10 +85,12 @@
},
{
"name": "semi_major_axis",
"type":"double",
"value": "6378137.0d"
},
{
"name": "inverse_flattening ",
"type":"double",
"value": "298.257223563d"
}
]
......@@ -200,12 +196,12 @@
{
"name": "profile",
"comment": "Unique identifier for each feature instance",
"javaValue":"dataProxy.getSVPProfileCount()"
"javaValue": "dataProxy.getSVPProfileCount()"
},
{
"name": "sampleCount",
"comment": "max number of sample for sound velocity profiles",
"javaValue":"dataProxy.getSVPMaxSampleCount()"
"javaValue": "dataProxy.getSVPMaxSampleCount()"
}
],
"types": [],
......@@ -337,10 +333,7 @@
],
"type": "float",
"attributes": [
{
"name": "csr",
"value": "vsc"
},
{
"name": "valid_min",
"value": "0.0",
......@@ -799,7 +792,7 @@
{
"name": "time",
"comment": "can be fixed or unlimited length, as appropriate",
"javaValue":"dataProxy.getSurfaceSoundSpeedCount()"
"javaValue": "dataProxy.getSurfaceSoundSpeedCount()"
}
],
"types": [],
......@@ -940,7 +933,7 @@
{
"name": "time",
"comment": "can be fixed or unlimited length, as appropriate",
"javaValue":"dataProxy.getSwathCount()"
"javaValue": "dataProxy.getSwathCount()"
}
],
"types": [],
......@@ -1009,7 +1002,7 @@
{
"name": "time",
"comment": "can be fixed or unlimited length, as appropriate",
"javaValue":"dataProxy.getSwathCount()"
"javaValue": "dataProxy.getSwathCount()"
}
],
"types": [],
......@@ -2252,6 +2245,10 @@
{
"name": "units",
"value": "nanoseconds since 1601-01-01 00:00:00Z"
},
{
"name": "coordinates",
"value": "time latitude longitude"
}
]
}
......@@ -2341,6 +2338,10 @@
{
"name": "long_name",
"value": "Platform heading(true)"
},
{
"name": "coordinates",
"value": "time latitude longitude"
}
]
},
......@@ -2364,6 +2365,10 @@
{
"name": "long_name",
"value": "degree"
},
{
"name": "coordinates",
"value": "time latitude longitude"
}
]
},
......@@ -2392,6 +2397,10 @@
"name": "valid_min",
"value": "0.0",
"type": "float"
},
{
"name": "coordinates",
"value": "time latitude longitude"
}
]
},
......@@ -2420,6 +2429,10 @@
"name": "valid_min",
"value": "0.0",
"type": "float"
},
{
"name": "coordinates",
"value": "time latitude longitude"
}
]
},
......@@ -2443,6 +2456,10 @@
{
"name": "long_name",
"value": "height_above_reference_ellipsoid"
},
{
"name": "coordinates",
"value": "time latitude longitude"
}
]
},
......@@ -2466,6 +2483,10 @@
{
"name": "long_name",
"value": "altitude"
},
{
"name": "coordinates",
"value": "time latitude longitude"
}
]
},
......@@ -2490,6 +2511,10 @@
"name": "valid_min",
"value": "0.0",
"type": "float"
},
{
"name": "coordinates",
"value": "time latitude longitude"
}
]
}
......@@ -2788,7 +2813,7 @@
{
"name": "time",
"comment": "can be fixed or unlimited length, as appropriate",
"javaValue":"nEntries"
"javaValue": "nEntries"
}
],
"coordinatevariables": [
......@@ -4959,7 +4984,7 @@
"name": "filenames",
"comment": "Can be of fixed or unlimited length, as appropriate.",
"value": "unlimited",
"javaValue":"1"
"javaValue": "1"
}
],
"types": [],
......@@ -5023,6 +5048,10 @@
"name": "float(*) sample_t",
"comment": "Variable length vector used to store ragged arrays of backscatter data. Data type can be varied to suit data storage needs."
},
{
"name": "byte(*) sample_byte_t",
"comment": "Variable length vector used to store ragged arrays of backscatter data. Data type can be varied to suit data storage needs."
},
{
"name": "float(*) angle_t",
"comment": "Variable length vector used to store ragged arrays of split-aperture angles. Data type can varied to suit data storage needs."
......@@ -5081,14 +5110,11 @@
"comment": "Can be of fixed or unlimited length, as appropriate.",
"value": "unlimited",
"javaValue": "dataProxy.getSwathCount()"
},
{
"name": "tx_beam",
"comment": "The number of transmit beams in this beam group",
"javaValue": "dataProxy.getTxSectorCount()"
}
],
"coordinatevariables": [
......@@ -5135,6 +5161,10 @@
{
"name": "units",
"value": "nanoseconds since 1601-01-01 00:00:00Z"
},
{
"name": "coordinates",
"value": "ping_time platform_latitude platform_longitude"
}
]
}
......@@ -5157,13 +5187,16 @@
"name": "preferred_MRU",
"obligation": "MA",
"comment": "Index of the MRU sensor to use by default. If the sensor used can be dynamically changed, refer to the variable active_MRU. Index matches the ones used in the Platform MRU sensors variables.",
"type": "int"
"type": "int",
"value": "0"
},
{
"name": "preferred_position",
"obligation": "MA",
"comment": "Index of the position sensor to use by default. If the sensor used can be dynamically changed, refer to the variable active_position_sensor. Index matches the ones used in the Platform position sensors variables.",
"type": "int"
"type": "int",
"value": "0"
}
],
"variables": [
......@@ -5198,12 +5231,18 @@
"beam",
"subbeam"
],
"type": "sample_t",
"type": "sample_byte_t",
"attributes": [
{
"name": "long_name",
"value": "Raw backscatter measurements (real part)"
},
{
"name": "scale_factor",
"value": "0.5",
"type": "float"
},
{
"name": "units",
"value": "as appropriate",
......@@ -5274,7 +5313,6 @@
"name": "long_name",
"value": "Major angle scaling factor"
},
{
"name": "units",
"value": "1"
......@@ -5286,7 +5324,6 @@
}
]
},
{
"name": "echoangle_minor_sensitivity",
"obligation": "MA",
......@@ -5300,7 +5337,6 @@
"name": "long_name",
"value": "Minor angle scaling factor"
},
{
"name": "units",
"value": "1"
......@@ -5657,6 +5693,10 @@
{
"name": "long_name",
"value": "Beam stabilisation applied (or not)"
},
{
"name": "coordinates",
"value": "ping_time platform_latitude platform_longitude"
}
]
},
......@@ -5664,8 +5704,7 @@
"name": "beam_type",
"obligation": "M",
"comment": "Type of split-aperture beam (or not).",
"dims": [
],
"dims": [],
"type": "beam_t",
"attributes": [
{
......@@ -5741,6 +5780,10 @@
{
"name": "long_name",
"value": "Presence or not of non-quantitative processing applied to the backscattering data (sonar specific)"
},
{
"name": "coordinates",
"value": "ping_time platform_latitude platform_longitude"
}
]
},
......@@ -5785,6 +5828,10 @@
"name": "valid_min",
"value": "0.0",
"type": "float"
},
{
"name": "coordinates",
"value": "ping_time platform_latitude platform_longitude"
}
]
},
......@@ -5868,6 +5915,10 @@
{
"name": "units",
"value": "dB"
},
{
"name": "coordinates",
"value": "ping_time platform_latitude platform_longitude"
}
]
},
......@@ -6090,7 +6141,6 @@
"obligation": "MA",
"comment": "Receiving or monostatic transducer index associated with the given beam",
"dims": [
"ping_time",
"beam"
],
"type": "int",
......@@ -6121,6 +6171,10 @@
{
"name": "long_name",
"value": "Active MRU sensor index"
},
{
"name": "coordinates",
"value": "ping_time platform_latitude platform_longitude"
}
]
},
......@@ -6140,6 +6194,10 @@
{
"name": "long_name",
"value": "Active position sensor index"
},
{
"name": "coordinates",
"value": "ping_time platform_latitude platform_longitude"
}
]
},
......@@ -6168,6 +6226,10 @@
{
"name": "standard_name",
"value": "speed_of_sound_in_sea_water"
},
{
"name": "coordinates",
"value": "ping_time platform_latitude platform_longitude"
}
]
},
......@@ -6196,6 +6258,10 @@
{
"name": "long_name",
"value": "latitude"
},
{
"name": "coordinates",
"value": "ping_time platform_latitude platform_longitude"
}
]
},
......@@ -6224,6 +6290,10 @@
{
"name": "long_name",
"value": "longitude"
},
{
"name": "coordinates",
"value": "ping_time platform_latitude platform_longitude"
}
]
},
......@@ -6252,6 +6322,10 @@
"name": "valid_range",
"value": "0f, 360.0f",
"type": "float"
},
{
"name": "coordinates",
"value": "ping_time platform_latitude platform_longitude"
}
]
},
......@@ -6280,6 +6354,10 @@
"name": "valid_range",
"value": "-90.0f, 90.0f",
"type": "float"
},
{
"name": "coordinates",
"value": "ping_time platform_latitude platform_longitude"
}
]
},
......@@ -6303,6 +6381,10 @@
{
"name": "long_name",
"value": "roll angle"
},
{
"name": "coordinates",
"value": "ping_time platform_latitude platform_longitude"
}
]
},
......@@ -6322,6 +6404,10 @@
{
"name": "units",
"value": "m"
},
{
"name": "coordinates",
"value": "ping_time platform_latitude platform_longitude"
}
]
},
......@@ -6341,6 +6427,10 @@
{
"name": "units",
"value": "m"
},
{
"name": "coordinates",
"value": "ping_time platform_latitude platform_longitude"
}
]
},
......@@ -6361,6 +6451,10 @@
"name": "units",
"value": "m"
},
{
"name": "coordinates",
"value": "ping_time platform_latitude platform_longitude"
},
{
"name": "vertical_coordinate_reference_system",
"value": "MSL depth",
......
......@@ -21,56 +21,59 @@ public class NetcdfLayerDeclarer {
}
static String getClassicLayerClass(int dim, DataType type)
{
if (dim == 0) dim=1;
switch (type) {
case BOOLEAN:
return 0 == dim || dim == 1 ? "BooleanLoadableLayer1D": "BooleanLoadableLayer2D";
return "BooleanLoadableLayer"+dim+"D";
case BYTE:
return 0 == dim || dim == 1 ? "ByteLoadableLayer1D" : "ByteLoadableLayer2D";
return "ByteLoadableLayer"+dim+"D";
case CHAR:
return 0 == dim || dim == 1 ? "ShortLoadableLayer1D" : "ShortLoadableLayer2D";
return "ShortLoadableLayer"+dim+"D";
case UBYTE:
case SHORT:
return 0 == dim || dim == 1 ? "ShortLoadableLayer1D" : "ShortLoadableLayer2D";
return "ShortLoadableLayer"+dim+"D";
case USHORT:
case INT:
return 0 == dim || dim == 1 ? "IntLoadableLayer1D" : "IntLoadableLayer2D";
return "IntLoadableLayer"+dim+"D";
case UINT:
case LONG:
case ULONG:
return 0 == dim || dim == 1 ? "LongLoadableLayer1D" : "LongLoadableLayer2D";
return "LongLoadableLayer"+dim+"D";
case FLOAT:
return 0 == dim || dim == 1 ? "FloatLoadableLayer1D" : "FloatLoadableLayer2D";
return "FloatLoadableLayer"+dim+"D";
case DOUBLE:
return 0 == dim || dim == 1 ? "DoubleLoadableLayer1D": "DoubleLoadableLayer2D";
return "DoubleLoadableLayer"+dim+"D";
case STRING:
return 0 == dim || dim == 1 ? "StringLoadableLayer1D": "StringLoadableLayer2D";
return "StringLoadableLayer"+dim+"D";
default:
return null;
}
}
static String getVlenLayerClass(int dim, DataType type)
{
if (dim == 0) dim=1;
switch (type) {
case BOOLEAN:
return 0 == dim || dim == 1 ? "BooleanVlenLoadableLayer1D": "BooleanVlenLoadableLayer2D";
return "BooleanVlenLoadableLayer"+dim+"D";
case BYTE:
return 0 == dim || dim == 1 ? "ByteVlenLoadableLayer1D" : "ByteVlenLoadableLayer2D";
return "ByteVlenLoadableLayer"+dim+"D";
case CHAR:
return 0 == dim || dim == 1 ? "ShortVlenLoadableLayer1D" : "ShortVlenLoadableLayer2D";
return "ShortVlenLoadableLayer"+dim+"D";
case UBYTE:
case SHORT:
return 0 == dim || dim == 1 ? "ShortVlenLoadableLayer1D" : "ShortVlenLoadableLayer2D";
return "ShortVlenLoadableLayer"+dim+"D";
case USHORT:
case INT:
return 0 == dim || dim == 1 ? "IntVlenLoadableLayer1D" : "IntVlenLoadableLayer2D";
return "IntVlenLoadableLayer"+dim+"D";
case UINT:
case LONG:
case ULONG:
return 0 == dim || dim == 1 ? "LongVlenLoadableLayer1D" : "LongVlenLoadableLayer2D";
return "LongVlenLoadableLayer"+dim+"D";
case FLOAT:
return 0 == dim || dim == 1 ? "FloatVlenLoadableLayer1D" : "FloatVlenLoadableLayer2D";
return "FloatVlenLoadableLayer"+dim+"D";
case DOUBLE:
return 0 == dim || dim == 1 ? "DoubleVlenLoadableLayer1D": "DoubleVlenLoadableLayer2D";
return "DoubleVlenLoadableLayer"+dim+"D";
default:
return null;
}
......
......@@ -202,7 +202,10 @@ public class PredefinedLayersGenerator {
if(long_name.isPresent())
{
longName=long_name.get().getValue();
if(long_name.get().getSubcomment()!=null)
longName+=long_name.get().getSubcomment();
}
String layerClass=NetcdfLayerDeclarer.getLayerClass(v.getDims().size(),baselayerType, expandedlayerType);
return new Layer(lPath,layerName, layerClass,v.getName(), longName, DataKind.continuous.toString(), unit, lPath);
......
......@@ -7,14 +7,14 @@ import java.util.Map;
import java.util.SortedSet;
import java.util.TreeSet;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.text.WordUtils;
import org.apache.poi.ss.formula.eval.NotImplementedException;
import fr.ifremer.fr.xsf.generator.DataTypeConverter;
public class SCGroupAdapter {
private static boolean forceVariableDeclaration=false;
private static boolean forceVariableDeclaration = false;
private static Map<Group, String> groupToClassName = new HashMap<>();
/** @return class name **/
......@@ -28,8 +28,9 @@ public class SCGroupAdapter {
String groupName = StringUtils.deleteWhitespace(WordUtils.capitalizeFully(group.name.replace("_", " ")));
if (groupName.contentEquals("VendorSpecific")) {
String [] sp = groupPath.split("/");
String prefix = StringUtils.deleteWhitespace(WordUtils.capitalizeFully(sp[sp.length - 2].replace("_", " ")));
String[] sp = groupPath.split("/");
String prefix = StringUtils
.deleteWhitespace(WordUtils.capitalizeFully(sp[sp.length - 2].replace("_", " ")));
className = prefix + "VendorSpecific";
} else {
......@@ -37,18 +38,19 @@ public class SCGroupAdapter {
}
if (className.isEmpty())
className="Root";
if (!className.endsWith("Group"))
className = "Root";
if (!className.endsWith("Group"))
className += "Grp";
groupToClassName.put(group, className);
return className;
}
/**
* Generates a source file for a specific group
*/
public static List<String> getSourceCode(String path, Group group, String outputPackage, boolean isSpecific){
public static List<String> getSourceCode(String path, Group group, String outputPackage, boolean isSpecific) {
// Build file contents
List<String> sourceCode = new ArrayList<>();
......@@ -77,26 +79,23 @@ public class SCGroupAdapter {
sourceCode.add(String.format("\n/** Class generated by %s **/", SCGroupAdapter.class.getSimpleName()));
sourceCode.add("@SuppressWarnings(\"unused\")");
sourceCode.add(String.format("public class %s extends NCGroup {", getClassName(group, "")));
// Group name
//if group is a sensor, group name is computed