Exemplo n.º 1
0
 /**
  * Gets a specified row as a fault trace
  *
  * @param row
  */
 public LocationList getRowAsTrace(int row) {
   List<Location> locs = Lists.newArrayList();
   for (int col = 0; col < getNumCols(); col++) {
     locs.add(get(row, col));
   }
   return LocationList.create(locs);
 }
Exemplo n.º 2
0
 @Override
 public LocationList getEvenlyDiscritizedListOfLocsOnSurface() {
   return LocationList.create(this);
   // LocationList locList = new LocationList();
   // Iterator<Location> it = listIterator();
   // while(it.hasNext()) locList.add((Location)it.next());
   // return locList;
 }
Exemplo n.º 3
0
    @Override
    public SiteSet deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context)
        throws JsonParseException {

      Builder builder = Site.builder();

      // check if we have a site list
      if (json.isJsonArray()) {
        Type type = new TypeToken<List<Site>>() {}.getType();
        List<Site> sites = context.deserialize(json, type);
        return new SiteSet(sites);
      }

      // or a region
      JsonObject jRegion = json.getAsJsonObject().getAsJsonObject(REGION);

      if (jRegion.has(VS30.toString())) {
        double vs30 = jRegion.get(VS30.toString()).getAsDouble();
        builder.vs30(vs30);
      }

      if (jRegion.has(VS_INF.toString())) {
        boolean vsInf = jRegion.get(VS_INF.toString()).getAsBoolean();
        builder.vsInferred(vsInf);
      }

      if (jRegion.has(Z1P0.toString())) {
        double z1p0 = jRegion.get(Z1P0.toString()).getAsDouble();
        builder.z1p0(z1p0);
      }

      if (jRegion.has(Z2P5.toString())) {
        double z2p5 = jRegion.get(Z2P5.toString()).getAsDouble();
        builder.z2p5(z2p5);
      }

      checkState(jRegion.has(BORDER), "Site region must define a border");
      checkState(jRegion.has(SPACING), "Site region must define a spacing");

      String name = "Unnamed region";
      if (jRegion.has(NAME.toString())) {
        name = jRegion.get(NAME.toString()).getAsString();
      }

      double spacing = jRegion.get(SPACING).getAsDouble();

      JsonArray coords = jRegion.getAsJsonArray(BORDER);
      LocationList.Builder borderBuilder = LocationList.builder();
      for (JsonElement jElem : coords) {
        JsonArray coord = jElem.getAsJsonArray();
        borderBuilder.add(coord.get(1).getAsDouble(), coord.get(0).getAsDouble());
      }
      LocationList border = borderBuilder.build();

      checkState(border.size() >= 2, "Site region border must define at " + "least 2 coordinates");

      GriddedRegion region =
          (border.size() == 2)
              ? Regions.createRectangularGridded(
                  name, border.get(0), border.get(1), spacing, spacing, GriddedRegion.ANCHOR_0_0)
              : Regions.createGridded(
                  name, border, MERCATOR_LINEAR, spacing, spacing, GriddedRegion.ANCHOR_0_0);

      return new SiteSet(region, builder);
    }