Merge branch 'master' into bug5280

This commit is contained in:
Axel Uhl committed 2020-05-15 00:21:32 +02:00
commit f95ef0723c
3 files changed
+18 -8

No files matched your search

@@ -0,0 +1,3 @@
{"rms":[
{"NatAuth":"UKR","BIN":"UKR0267_Karina","CertNo":"0267_4","RefNo":"03600000HUH","SailNo":"UKR 267","YachtName":"Karina","Class":"Teliga 89","Builder":"im. L Teligi","Designer":"L. Teliga","Address3":"YC Obolon","C_Type":"CLUB","Family":"ORC","Division":"C","IssueDate":"2020-05-07T11:48:07.143Z","Age_Year":1975,"CrewWT":460,"LOA":8.95,"IMSL":7.354,"Draft":1.562,"MB":3.092,"Dspl_Measurement":3790,"Stability_Index":107.3,"Dynamic_Allowance":0.328,"GPH":725.4,"TMF_Inshore":0.8568,"ILCWA":787.8,"TMF_Offshore":0.849,"OSN":706.7,"CDL":6.694,"TN_Offshore_Low":0.8193,"TN_Offshore_Medium":1.0478,"TN_Offshore_High":1.1557,"TN_Inshore_Low":0.6372,"TN_Inshore_Medium":0.8543,"TN_Inshore_High":0.9652,"TND_Offshore_Low":823.9,"TND_Offshore_Medium":644.2,"TND_Offshore_High":584.1,"TND_Inshore_Low":1059.3,"TND_Inshore_Medium":790.1,"TND_Inshore_High":699.3,"OSN_Jibs":735.4,"TMF_Jibs":0.8158,"Pred_Up_TOD":708.3,"Pred_Down_TOD":650.3,"Pred_Up_TOT":0.8471,"Pred_Down_TOT":0.9227,"Dspl_Sailing":4377,"WSS":18.58,"Area_Main":17.88,"Area_Jib":33.38,"Area_Sym":71.46,"Area_ASym":56.06,"GPH_Jibs":757.5,"GPH_Jibs_TOT":0.7921,"Allowances":{"WindSpeeds":[6,8,10,12,14,16,20],"WindAngles":[52,60,75,90,110,120,135,150],"Beat":[1215.6,1032.2,921.7,859.4,840,835.1,853.2],"Run":[1102.9,886.5,746.4,655.8,596.9,564.7,518.9],"BeatAngle":[42.8,42,42.8,41.4,40.9,40.7,41.8],"GybeAngle":[148,152,150.5,162,180,180,180],"WL":[1159.2,959.4,834.1,757.6,718.4,699.9,686],"CR":[989.5,803.2,704.2,647.7,614.3,594,572.2],"OC":[1153.6,900.2,752.5,666.7,624.4,593.1,543.1],"NS":[1044.7,843.1,734.6,671.9,634.2,611.1,586],"OL":[1116.2,923.6,815.1,753.8,722.7,706.6,697.2],"R52":[796.9,680.2,617.6,591.6,581.2,577.6,579],"R60":[753.3,644.5,598.1,576.8,565.2,560.4,559.4],"R75":[723,622.2,584.2,564,549,537.5,528],"R90":[729.8,623.6,577.4,552.9,539.1,527.4,503.9],"R110":[729.1,608.7,564.9,538.7,516.9,499.7,477.8],"R120":[750.3,617.8,568.6,540.6,515,493.4,466],"R135":[817.4,671.3,588.5,556.1,530.2,505,465.1],"R150":[955.2,767.9,647,584.3,555.6,531.9,487.7]}}
]}
@@ -13,6 +13,11 @@ public class TestORCCertificateImporterJSON extends AbstractORCCertificateImport
testSimpleLocalFileRead("GER2019.json", "GER20041179");
}
@Test
public void testReadingJSONWithSpecificBins() throws IOException, ParseException {
testSimpleLocalFileRead("03600000HUH.json", "03600000HUH");
}
@FailIfNoValidOrcCertificates
@Test
public void testSimpleOnlineJSONFileRead() throws IOException, ParseException, InterruptedException {
@@ -63,6 +63,7 @@ public class ORCCertificatesCollectionJSON extends AbstractORCCertificatesCollec
private static final String CIRCULAR_RANDOM = "CR";
private static final String NON_SPINNAKER = "NS";
private static final String WIND_SPEEDS = "WindSpeeds";
private static final String WIND_ANGLES = "WindAngles";
/**
* Pattern to recognize a true wind angle in the allowances section. Group 1 contains
@@ -189,27 +190,28 @@ public class ORCCertificatesCollectionJSON extends AbstractORCCertificatesCollec
}
// Now read the various allowances, assuming we find values for the TWS "bins" identified above
for (final Object aKey : allowances.keySet()) {
final JSONArray array = (JSONArray) allowances.get(aKey);
final JSONArray twaArray = (JSONArray) allowances.get(aKey);
if (((String) aKey).equals(BEAT_ANGLE)) {
for (int i = 0; i < array.size(); i++) {
for (int i = 0; i < twaArray.size(); i++) {
beatAngles.put(new KnotSpeedImpl(trueWindSpeedArray[i]),
new DegreeBearingImpl(((Number) array.get(i)).doubleValue()));
new DegreeBearingImpl(((Number) twaArray.get(i)).doubleValue()));
}
continue;
}
if (((String) aKey).equals(GYBE_ANGLE)) {
for (int i = 0; i < array.size(); i++) {
for (int i = 0; i < twaArray.size(); i++) {
gybeAngles.put(new KnotSpeedImpl(trueWindSpeedArray[i]),
new DegreeBearingImpl(((Number) array.get(i)).doubleValue()));
new DegreeBearingImpl(((Number) twaArray.get(i)).doubleValue()));
}
continue;
}
Map<Speed, Duration> twsMap = new HashMap<>();
// ignore true wind angles key
if (!twaPattern.matcher((String) aKey).lookingAt()) {
for (int i = 0; i < array.size(); i++) {
if (!aKey.equals(WIND_SPEEDS) && !aKey.equals(WIND_ANGLES) &&
!twaPattern.matcher((String) aKey).lookingAt()) {
for (int i = 0; i < twaArray.size(); i++) {
twsMap.put(new KnotSpeedImpl(trueWindSpeedArray[i]),
new SecondsDurationImpl(((Number) array.get(i)).doubleValue()));
new SecondsDurationImpl(((Number) twaArray.get(i)).doubleValue()));
}
}
switch ((String) aKey) {