def generate_PCR_6_default_config(self, filename): """Generate the WinnForum configuration for PCR 6.""" # File path where SAS UUT claimed ppa boundary generated in PCR.1 test pcr_1_test_config_file_path = os.path.join('testcases', 'configs', 'test_WINNF_FT_S_PCR_1', 'default.config') sas_uut_claimed_ppa_boundary_file_path = getSasUutClaimedPpaBoundaryFilePath( 'default.config') # Load SAS UUT claimed ppa boundary and check if any error while retrieving # SAS UUT claimed ppa boundary generated in PCR.1 test. try: with open(sas_uut_claimed_ppa_boundary_file_path, 'r') as claimed_ppa_file: user_claimed_ppa_contour = json.load(claimed_ppa_file) except IOError: raise RuntimeError( 'ConfigError:There is an error in reading path:%s \n\n' % sas_uut_claimed_ppa_boundary_file_path) # Expand the user claimed ppa boundary by approximately 1 kilometer. user_claimed_ppa_contour_feature_collection = utils.InsureFeatureCollection( utils.ShrinkAndCleanPolygon( user_claimed_ppa_contour['features'][0]['geometry'], -1e-2), as_dict=True) # Create the actual config. config = { 'configPCR_1': pcr_1_test_config_file_path, 'userClaimedPpaContour': user_claimed_ppa_contour_feature_collection } writeConfig(filename, config)
def test_shrinks_polygon(self): with open(os.path.join(TEST_DIR, 'test_shrink.json'), 'r') as fd: ppa = json.load(fd) geometry = ppa['features'][0]['geometry'] self.assertTrue(geometry['type'], 'Polygon') spoly = utils.ToShapely(geometry) mpoly = sgeo.MultiPolygon( [sgeo.Point(0, 0).buffer(1), sgeo.Point(2, 0).buffer(0.1)]) poly1 = utils.ShrinkAndCleanPolygon(geometry, 1e-2) poly2 = utils.ShrinkAndCleanPolygon(spoly, 1e-2) self.assertTrue(poly2.area < spoly.area) with self.assertRaises(ValueError): poly = utils.ShrinkAndCleanPolygon(mpoly, 1e-2) self.assertEqual(poly1['type'], 'Polygon') self.assertTrue(isinstance(poly2, sgeo.Polygon)) spoly1 = utils.ToShapely(poly1) self.assertEqual(poly2.difference(spoly1).area, 0) self.assertEqual(spoly1.difference(poly2).area, 0)
def generate_PCR_7_default_config(self, filename): """Generate the WinnForum configuration for PCR 7.""" # File path where SAS UUT claimed ppa boundary generated in PCR.1 test pcr_1_test_config_file_path = os.path.join('testcases', 'configs', 'test_WINNF_FT_S_PCR_1', 'default.config') sas_uut_claimed_ppa_boundary_file_path = getSasUutClaimedPpaBoundaryFilePath( 'default.config') # Load SAS UUT claimed ppa boundary and check if any error while retrieving # SAS UUT claimed ppa boundary generated in PCR.1 test. try: with open(sas_uut_claimed_ppa_boundary_file_path, 'r') as overlapped_ppa_file: overlapping_ppa_contour = json.load(overlapped_ppa_file) except IOError: raise RuntimeError( 'ConfigError:There is an error in reading path:%s \n\n' % sas_uut_claimed_ppa_boundary_file_path) # Shrink the user claimed ppa boundary by approximately 1 kilometer. overlapping_ppa_contour_geometry = utils.ShrinkAndCleanPolygon( overlapping_ppa_contour['features'][0]['geometry'], 1e-2) # Create ppa_record where user claimed PPA contour will be replaced. overlapping_ppa_record = json.load( open(os.path.join('testcases', 'testdata', 'ppa_record_0.json'))) # Update the user_claimed ppa contour geometry required for overlaps ppa. overlapping_ppa_record['zone'] = { 'type': 'FeatureCollection', 'features': [{ 'type': 'Feature', 'properties': {}, 'geometry': overlapping_ppa_contour_geometry }] } # Load PCR.1 configuration. pcr_1_test_config = loadConfig(pcr_1_test_config_file_path) # Set the pal_record used in PCR.1 tests. pcr_1_pal_records = pcr_1_test_config['palRecords'] #updating the PPA record based on the PAL records overlapping_ppa_record['ppaInfo']['palId'] = [ pal['palId'] for pal in pcr_1_pal_records ] overlapping_ppa_record['id'] = 'zone/ppa/%s/%s/%s' % ( overlapping_ppa_record['creator'], overlapping_ppa_record['ppaInfo']['palId'][0], uuid.uuid4().hex) overlapping_ppa_record['ppaInfo']['ppaBeginDate'] = pcr_1_pal_records[ 0]['license']['licenseDate'] overlapping_ppa_record['ppaInfo'][ 'ppaExpirationDate'] = pcr_1_pal_records[0]['license'][ 'licenseExpiration'] # Create the actual config. config = { 'configPCR_1': pcr_1_test_config_file_path, 'overlapPpaRecord': overlapping_ppa_record } writeConfig(filename, config)