You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// I don't know if a default value makes sense here
549
+
550
+
}
541
551
else
542
552
{
543
-
is_array = false;
553
+
input_type = InputTypes::DOUBLE_TYPE;
544
554
Value *value_def = Pointer((get_full_json_schema_path() + "/" + name + "/oneOf/0/default value").c_str()).Get(declarations);
545
555
WBAssertThrow(value_def != nullptr,
546
556
"internal error: could not retrieve the default value at: "
@@ -556,8 +566,8 @@ namespace WorldBuilder
556
566
// check if there is a user defined value
557
567
if (Pointer((strict_base + "/" + name).c_str()).Get(parameters) != nullptr)
558
568
{
559
-
// there is a user defined value, so either case 2, 3 or 4.
560
-
if (is_array)
569
+
// there is a user defined value, so either case 2, 3 4, or 5.
570
+
if (input_type == InputTypes::ARRAY_TYPE)
561
571
{
562
572
Value *array = Pointer((strict_base + "/" + name).c_str()).Get(parameters);
563
573
@@ -690,6 +700,147 @@ namespace WorldBuilder
690
700
}
691
701
}
692
702
}
703
+
elseif (input_type == InputTypes::STRING_TYPE)
704
+
{
705
+
// case 5: a string. Get the string and decode it
706
+
std::string value = "";
707
+
708
+
try
709
+
{
710
+
value = Pointer((strict_base + "/" + name).c_str()).Get(parameters)->GetString();
711
+
}
712
+
catch (...)
713
+
{
714
+
WBAssertThrow(false, "Could not convert values of " << strict_base << "/" << name << " into a String. "
715
+
<< "The provided value was \"" << Pointer((strict_base + "/" + name).c_str()).Get(parameters)->GetString() << "\".");
716
+
}
717
+
if (value.substr(0,8) == "Litho1.0")
718
+
{
719
+
enum LayerType
720
+
{
721
+
// ASTHENOSPHERE,
722
+
LITHOSPHERE,
723
+
CRUST3,
724
+
CRUST2,
725
+
CRUST1,
726
+
SEDIMENT3,
727
+
SEDIMENT2,
728
+
SEDIMENT1,
729
+
ICE,
730
+
WATER,
731
+
MAX_LAYERTYPE
732
+
};
733
+
size_t colon_location = value.find(':');
734
+
WBAssertThrow(colon_location!= std::string::npos,"when chosing Litho1.0 you need to specify a subunit with the colon (:)." );
735
+
std::string rest_of_string = value.substr(colon_location); // TODO: improve and make more robust, look at gwb-dat example
736
+
while ((!rest_of_string.empty()) && (rest_of_string[0] == ''))
737
+
rest_of_string.erase(rest_of_string.begin());
738
+
while ((!rest_of_string.empty()) && (rest_of_string[0] == ':'))
739
+
rest_of_string.erase(rest_of_string.begin());
740
+
while ((!rest_of_string.empty()) && (rest_of_string[0] == ''))
741
+
rest_of_string.erase(rest_of_string.begin());
742
+
while ((!rest_of_string.empty()) && (rest_of_string[rest_of_string.size() - 1] == ''))
743
+
rest_of_string.erase(rest_of_string.end() - 1);
744
+
LayerType layer_type = LayerType::MAX_LAYERTYPE;
745
+
if (rest_of_string == "lithosphere")
746
+
{
747
+
layer_type = LayerType::LITHOSPHERE;
748
+
}
749
+
elseif (rest_of_string == "crust 3")
750
+
{
751
+
layer_type = LayerType::CRUST3;
752
+
}
753
+
elseif (rest_of_string == "crust 2")
754
+
{
755
+
layer_type = LayerType::CRUST2;
756
+
}
757
+
elseif (rest_of_string == "crust 1")
758
+
{
759
+
layer_type = LayerType::CRUST1;
760
+
}
761
+
elseif (rest_of_string == "sediment 3")
762
+
{
763
+
layer_type = LayerType::SEDIMENT3;
764
+
}
765
+
elseif (rest_of_string == "sediment 2")
766
+
{
767
+
layer_type = LayerType::SEDIMENT2;
768
+
}
769
+
elseif (rest_of_string == "sediment 1")
770
+
{
771
+
layer_type = LayerType::SEDIMENT1;
772
+
}
773
+
elseif (rest_of_string == "ice")
774
+
{
775
+
layer_type = LayerType::ICE;
776
+
}
777
+
elseif (rest_of_string == "water")
778
+
{
779
+
layer_type = LayerType::WATER;
780
+
}
781
+
WBAssertThrow(layer_type != LayerType::MAX_LAYERTYPE, "Could not find litho1.0 layer type " << rest_of_string);
782
+
std::string litho_1_0_path = "";
783
+
Value *value_pointer = Pointer("/Litho1.0 path").Get(parameters);
784
+
WBAssertThrow(value_pointer != nullptr, "You are using the Litho1.0 dataset, but you have not specified the path to the dataset. Please add below \"version\": \"Litho1.0 path\". ");
785
+
try
786
+
{
787
+
litho_1_0_path = value_pointer->GetString();
788
+
}
789
+
catch (...)
790
+
{
791
+
WBAssertThrow(false, "Could not convert values of /Litho1.0 path into a String. ");
0 commit comments