コード例 #1
0
  public void read(AbstractBuilding building, long parentId) throws SQLException {
    ResultSet rs = null;

    try {
      psBuildingInstallation.setLong(1, parentId);
      rs = psBuildingInstallation.executeQuery();

      while (rs.next()) {
        long installationId = rs.getLong("ID");
        int isExternal = rs.getInt("IS_EXTERNAL");

        BuildingInstallation buildingInstallation = null;
        IntBuildingInstallation intBuildingInstallation = null;

        if (isExternal == 1) buildingInstallation = new BuildingInstallationImpl();
        else intBuildingInstallation = new IntBuildingInstallationImpl();

        String gmlName = rs.getString("NAME");
        String gmlNameCodespace = rs.getString("NAME_CODESPACE");

        if (buildingInstallation != null)
          Util.dbGmlName2featureName(buildingInstallation, gmlName, gmlNameCodespace);
        else Util.dbGmlName2featureName(intBuildingInstallation, gmlName, gmlNameCodespace);

        String description = rs.getString("DESCRIPTION");
        if (description != null) {
          StringOrRef stringOrRef = new StringOrRefImpl();
          stringOrRef.setValue(description);

          if (buildingInstallation != null) buildingInstallation.setDescription(stringOrRef);
          else intBuildingInstallation.setDescription(stringOrRef);
        }

        String clazz = rs.getString("CLASS");
        if (clazz != null) {
          if (buildingInstallation != null) buildingInstallation.setClazz(clazz);
          else intBuildingInstallation.setClazz(clazz);
        }

        String function = rs.getString("FUNCTION");
        if (function != null) {
          Pattern p = Pattern.compile("\\s+");
          String[] functionList = p.split(function.trim());

          if (buildingInstallation != null)
            buildingInstallation.setFunction(Arrays.asList(functionList));
          else intBuildingInstallation.setFunction(Arrays.asList(functionList));
        }

        String usage = rs.getString("USAGE");
        if (usage != null) {
          Pattern p = Pattern.compile("\\s+");
          String[] usageList = p.split(usage.trim());

          if (buildingInstallation != null) buildingInstallation.setUsage(Arrays.asList(usageList));
          else intBuildingInstallation.setUsage(Arrays.asList(usageList));
        }

        for (int lod = 2; lod < 5; lod++) {
          long lodSurfaceGeometryId = rs.getLong("LOD" + lod + "_GEOMETRY_ID");

          if (!rs.wasNull() && lodSurfaceGeometryId != 0) {
            DBSurfaceGeometryResult geometry = surfaceGeometryExporter.read(lodSurfaceGeometryId);

            if (geometry != null) {
              GeometryProperty<AbstractGeometry> geometryProperty =
                  new GeometryPropertyImpl<AbstractGeometry>();

              if (geometry.getAbstractGeometry() != null)
                geometryProperty.setGeometry(geometry.getAbstractGeometry());
              else geometryProperty.setHref(geometry.getTarget());

              switch (lod) {
                case 2:
                  if (buildingInstallation != null)
                    buildingInstallation.setLod2Geometry(geometryProperty);
                  break;
                case 3:
                  if (buildingInstallation != null)
                    buildingInstallation.setLod3Geometry(geometryProperty);
                  break;
                case 4:
                  if (buildingInstallation != null)
                    buildingInstallation.setLod4Geometry(geometryProperty);
                  else intBuildingInstallation.setLod4Geometry(geometryProperty);
                  break;
              }
            }
          }
        }

        if (buildingInstallation != null) {
          cityObjectReader.read(buildingInstallation, installationId);

          BuildingInstallationProperty buildInstProp = new BuildingInstallationPropertyImpl();
          buildInstProp.setObject(buildingInstallation);
          building.addOuterBuildingInstallation(buildInstProp);
        } else {
          cityObjectReader.read(intBuildingInstallation, installationId);

          IntBuildingInstallationProperty intInstProp = new IntBuildingInstallationPropertyImpl();
          intInstProp.setObject(intBuildingInstallation);
          building.addInteriorBuildingInstallation(intInstProp);
        }
      }
    } finally {
      if (rs != null) rs.close();
    }
  }
コード例 #2
0
  public void read(Room room, long parentId) throws SQLException {
    ResultSet rs = null;

    try {
      psRoomInstallation.setLong(1, parentId);
      rs = psRoomInstallation.executeQuery();

      while (rs.next()) {
        long installationId = rs.getLong("ID");
        IntBuildingInstallation intBuildingInstallation = new IntBuildingInstallationImpl();

        String gmlName = rs.getString("NAME");
        String gmlNameCodespace = rs.getString("NAME_CODESPACE");

        Util.dbGmlName2featureName(intBuildingInstallation, gmlName, gmlNameCodespace);

        String description = rs.getString("DESCRIPTION");
        if (description != null) {
          StringOrRef stringOrRef = new StringOrRefImpl();
          stringOrRef.setValue(description);

          intBuildingInstallation.setDescription(stringOrRef);
        }

        String clazz = rs.getString("CLASS");
        if (clazz != null) {
          intBuildingInstallation.setClazz(clazz);
        }

        String function = rs.getString("FUNCTION");
        if (function != null) {
          Pattern p = Pattern.compile("\\s+");
          String[] functionList = p.split(function.trim());

          intBuildingInstallation.setFunction(Arrays.asList(functionList));
        }

        String usage = rs.getString("USAGE");
        if (usage != null) {
          Pattern p = Pattern.compile("\\s+");
          String[] usageList = p.split(usage.trim());

          intBuildingInstallation.setUsage(Arrays.asList(usageList));
        }

        long lodSurfaceGeometryId = rs.getLong("LOD4_GEOMETRY_ID");
        if (!rs.wasNull() && lodSurfaceGeometryId != 0) {
          DBSurfaceGeometryResult geometry = surfaceGeometryExporter.read(lodSurfaceGeometryId);

          if (geometry != null) {
            GeometryProperty<AbstractGeometry> geometryProperty =
                new GeometryPropertyImpl<AbstractGeometry>();

            if (geometry.getAbstractGeometry() != null)
              geometryProperty.setGeometry(geometry.getAbstractGeometry());
            else geometryProperty.setHref(geometry.getTarget());

            intBuildingInstallation.setLod4Geometry(geometryProperty);
          }
        }

        cityObjectReader.read(intBuildingInstallation, installationId);

        IntBuildingInstallationProperty intInstProp = new IntBuildingInstallationPropertyImpl();
        intInstProp.setObject(intBuildingInstallation);
        room.addRoomInstallation(intInstProp);
      }
    } finally {
      if (rs != null) rs.close();
    }
  }