Esempio n. 1
0
boost::optional<IdfObject> ForwardTranslator::translateSite( Site & modelObject )
{
  IdfObject site = createAndRegisterIdfObject(openstudio::IddObjectType::Site_Location,
                                              modelObject);

  OptionalString optS = modelObject.name();
  if(optS) {
    site.setName(*optS);
  }

  OptionalDouble od = modelObject.latitude();
  if(od) {
    site.setDouble(Site_LocationFields::Latitude, *od);
  }

  od = modelObject.longitude();
  if(od) {
    site.setDouble(Site_LocationFields::Longitude, *od);
  }

  od = modelObject.timeZone();
  if(od) {
    site.setDouble(Site_LocationFields::TimeZone, *od);
  }

  od = modelObject.elevation();
  if(od) {
    site.setDouble(Site_LocationFields::Elevation, *od);
  }

  // translate shading groups
  ShadingSurfaceGroupVector shadingSurfaceGroups = modelObject.shadingSurfaceGroups();
  std::sort(shadingSurfaceGroups.begin(), shadingSurfaceGroups.end(), WorkspaceObjectNameLess());
  for (ShadingSurfaceGroup& shadingSurfaceGroup : shadingSurfaceGroups){
    translateAndMapModelObject(shadingSurfaceGroup);
  }

  return boost::optional<IdfObject>(site);
}
Esempio n. 2
0
TEST_F(TestSite, Site)
{
    Site s = Site::create(m_engine, "test");
    ASSERT_TRUE(s);

    EXPECT_EQ(string("test"), s.name());
    EXPECT_EQ(m_engine, s.engine());
    EXPECT_TRUE(s.memory_pool());

    Location l = s.create_default_location();
    EXPECT_EQ(l, s.default_location());

    s.add_ip("1.2.3.4");
    EXPECT_EQ(1UL, s.ips().size());
    EXPECT_EQ(string("1.2.3.4"), s.ips().front());

    s.add_host("foo");
    EXPECT_EQ(1UL, s.hosts().size());
    EXPECT_EQ(string("foo"), s.hosts().front());

    l = s.create_location("/foo");
    EXPECT_EQ(1UL, s.locations().size());
    EXPECT_EQ(l, s.locations().front());
}