def assign_ref_shapes(self): # dictionary that containes pairs rank: Polygon _shapes = {} # extract API region where_clause = "FIPS_API = '%s'" % (self.get_5d_api()) table = 'GISCoreData.dbo.API_Regions_WM' polygon_WKT = queryWKT(table, where_clause) if polygon_WKT: poly = loads(polygon_WKT) _shapes['Api_region'] = poly #exctract section where_clause = "StateCode LIKE '%s' AND TWN LIKE '%s' AND TWNDIR LIKE '%s' AND RNG LIKE '%s' AND RNGDIR LIKE '%s'AND SECTION LIKE '%s'" % (self.state_code, self.twnshp, self.twnshp_dir, self.range_, self.range_dir, self.section) table = 'GISCoreData.dbo.PLSS_SEC_%i' % self.mcode polygon_WKT = queryWKT(table, where_clause) if polygon_WKT: poly = loads(polygon_WKT) _shapes['Section'] = poly # qqsection if exists if self.qqsection: where_clause = "TWN LIKE '%s' AND TWNDIR LIKE '%s' AND RNG LIKE '%s' AND RNGDIR LIKE '%s'AND SECTION LIKE '%s' AND qqsection like '%s%s'" % (self.twnshp, self.twnshp_dir, self.range_, self.range_dir, self.section, self.qsection, self.qqsection) table = 'GISCoreData.dbo.PLSS_QQ_%i' % self.mcode polygon_WKT = queryWKT(table, where_clause) if polygon_WKT: poly = loads(polygon_WKT) _shapes['qqSection'] = poly #TODO: add more conditions self.reference_shapes = _shapes
def assign_ref_shapes(self): # dictionary that containes pairs rank: Polygon _shapes = {} # extract API region where_clause = "FIPS_API = '%s'" % (self.get_5d_api()) table = 'GISCoreData.dbo.API_Regions_WM' polygon_WKT = queryWKT(table, where_clause) if polygon_WKT: poly = loads(polygon_WKT) _shapes['Api_region'] = poly #exctract Abstract where_clause = "COUNTY = '%s' AND ANUM1 = '%s'" % ( self.county.upper().strip(), self.abstract_no.strip()) table = 'GISCoreData.dbo.TexasSurveys' polygon_WKT = queryWKT(table, where_clause) if polygon_WKT: poly = loads(polygon_WKT) _shapes['Abstract'] = poly #TODO: add more conditions self.reference_shapes = _shapes
def coordinates(self): # variables self.mcode1 = self.rec.cty.mcode1 self.mcode2 = self.rec.cty.mcode2 self.mcode3 = self.rec.cty.mcode3 self.twnshp = self.rec.geo.twnshp.strip().zfill(3) self.twnshp_dir = self.rec.geo.twnshp_dir.upper().strip() self.range_ = self.rec.geo.range_.strip().zfill(3) self.range_dir = self.rec.geo.range_dir.upper().strip() self.section = self.rec.geo.section.strip().zfill(3) self.qsection = self.rec.geo.qsection.strip() if self.rec.geo.qsection else None self.qqsection = self.rec.geo.qqsection.strip() if self.rec.geo.qqsection else None self.offset_dir_1 = self.rec.geo.offset_dir_1.upper().strip() self.offset_dir_2 = self.rec.geo.offset_dir_2.upper().strip() try: self.offset_1 = float(self.rec.geo.offset_1) self.offset_2 = float(self.rec.geo.offset_2) except: print '\tCould not convert offsets to float: %s, %s' % (self.rec.geo.offset_1, self.rec.geo.offset_2) # define the meridian zone if any([self.mcode2, self.mcode3]): self.mcode = meridian_zone(self.state_code, self.county, self.twnshp, self.twnshp_dir, self.range_, self.range_dir) else: self.mcode = self.mcode1 self.legal_desc_str = '\tloc#: %s, api: %s, state: %s, county: %s, mcode: %i, leg_desc: %s, twnshp: %s, twnshp_dir: %s, range: %s, range_dir: %s, section: %s, qsection: %s, qqsection: %s, offset1: %s, offsetDir1: %s, offset2: %s, offsetDir2: %s' \ % (self.locnum, self.api, self.state_code, self.county, self.mcode, self.legal_desc, self.twnshp, self.twnshp_dir, self.range_, self.range_dir, self.section, self.qsection, self.qqsection, self.offset_1, self.offset_dir_1, self.offset_2, self.offset_dir_2) if not all([self.state_code, self.county, self.twnshp, self.twnshp_dir, self.range_, self.range_dir, self.section, self.offset_1, self.offset_2, self.offset_dir_1, self.offset_dir_2]): # self.point is None, assigned in constructor return where_clause = "StateCode LIKE '%s' AND TWN LIKE '%s' AND TWNDIR LIKE '%s' AND RNG LIKE '%s' AND RNGDIR LIKE '%s'AND SECTION LIKE '%s'" % (self.state_code, self.twnshp, self.twnshp_dir, self.range_, self.range_dir, self.section) table = 'GISCoreData.dbo.PLSS_SEC_%i' % self.mcode wkt = queryWKT(table, where_clause) if not wkt or len(self.offset_dir_1) > 3 or len(self.offset_dir_2) > 3: # self.point is None, assigned in constructor return # print wkt detector = CornerDetector(wkt) if detector.get_four_corners(): # print detector self.point = calc_point_from_offsets(detector.get_four_corners(), self.offset_1, self.offset_dir_1, self.offset_2, self.offset_dir_2, units='feet') else: print '\tunable to extract four corners from the referenced shape'
def coordinates(self): # variables self.map_sheet = self.rec.geo.map_sheet.strip() self.unit = self.rec.geo.unit.strip() self.quarter_unit = self.rec.geo.quarter_unit.strip() self.block = self.rec.geo.block.strip() # offset direction values are ignored # they are determined below from the negative or positive offset values try: self.offset_1 = float(self.rec.geo.offset_1) self.offset_2 = float(self.rec.geo.offset_2) except: print '\tCould not convert offsets to float: %s, %s' % ( self.rec.geo.offset_1, self.rec.geo.offset_2) self.legal_desc_str = '\tloc#: %s, uwi: %s, province: %s, mapsheet: %s, block: %s, unit: %s, qunit: %s, offset_NS: %s, offset_EW: %s' \ % (self.locnum, self.uwi, self.province_code, self.map_sheet, self.block, self.unit, self.quarter_unit, self.offset_1, self.offset_2) if not all([ self.province_code, self.map_sheet, self.block, self.unit, self.quarter_unit, self.offset_1, self.offset_2 ]): # self.point is None, assigned in constructor return where_clause = "MAPSHEET = '%s' AND BLOCK = '%s' AND UNIT = %i" % ( self.map_sheet, self.block, int(self.unit)) table = 'GISCoreData.dbo.TS_%s_UNITS' % self.province_code wkt = queryWKT(table, where_clause) if not wkt: # self.point is None, assigned in constructor return # print wkt detector = CornerDetector(wkt) if detector.get_four_corners(): # directions are determined from the offset values. offset_dir_1 = 'FSL' if self.offset_1 > 0 else 'FNL' offset_dir_2 = 'FWL' if self.offset_2 > 0 else 'FEL' # the offset values are passed as positive values to the calc_point_from_offset funcion self.point = calc_point_from_offsets(detector.get_four_corners(), abs(self.offset_1), offset_dir_1, abs(self.offset_2), offset_dir_2, units='meters') else: print '\tunable to extract four corners from the referenced shape'
def coordinates(self): # variables self.twnshp = self.rec.geo.twnshp.strip() self.range_ = self.rec.geo.range_.strip() self.meridian = self.rec.geo.meridian.strip() self.section = self.rec.geo.section.strip() self.lsd = self.rec.geo.legal_subdivision.strip() if self.rec.geo.legal_subdivision else None self.qsection = self.rec.geo.qsection.strip() if self.rec.geo.qsection else None self.qqsection = self.rec.geo.qqsection.strip() if self.rec.geo.qqsection else None self.offset_dir_1 = self.rec.geo.offset_dir_1.upper().strip() self.offset_dir_2 = self.rec.geo.offset_dir_2.upper().strip() try: self.offset_1 = float(self.rec.geo.offset_1) self.offset_2 = float(self.rec.geo.offset_2) except: print '\tCould not convert offsets to float: %s, %s' % (self.rec.geo.offset_1, self.rec.geo.offset_2) # flip directions: because the source directions for Canada (SK, AB and MB)are just entered the opposite what they should have been self.offset_dir_1 = Alberta_Saskatchewan_dls.flip_directions.get(self.offset_dir_1) self.offset_dir_2 = Alberta_Saskatchewan_dls.flip_directions.get(self.offset_dir_2) if not all([self.offset_dir_1, self.offset_dir_2]): raise DirectionException("Wrong direction values: (%s, %s)" % (self.rec.geo.offset_dir_1.upper().strip(), self.rec.geo.offset_dir_2.upper().strip())) self.legal_desc_str = '\tloc#: %s, uwi: %s, province: %s, meridian: %s, twn: %s, rng: %s, section: %s, lsd: %s, offset1: %.2f, offset_dir1: %s, offset2: %.2f, offset_dir2: %s' \ % (self.locnum, self.uwi, self.province_code, self.meridian, self.twnshp, self.range_, self.section, self.lsd, self.offset_1, self.offset_dir_1, self.offset_2, self.offset_dir_2) if not all([self.province_code, self.meridian, self.twnshp, self.range_, self.section, self.offset_1, self.offset_dir_1, self.offset_2, self.offset_dir_2]): # self.point is None, assigned in constructor return where_clause = "MER = '%s' AND TWN = '%s' AND RNG = '%s' AND SEC = '%s'" % (self.meridian, self.twnshp, self.range_, self.section) table = 'GISCoreData.dbo.DLS_%s_SEC' % self.province_code wkt = queryWKT(table, where_clause) if not wkt: # self.point is None, assigned in constructor return # print wkt detector = CornerDetector(wkt) if detector.get_four_corners(): # print detector self.point = calc_point_from_offsets(detector.get_four_corners(), self.offset_1, self.offset_dir_1, self.offset_2, self.offset_dir_2, units='meters') else: print '\tunable to extract four corners from the referenced shape'
def assign_ref_shapes(self): # dictionary that containes pairs rank: Polygon _shapes = {} # extract API region where_clause = "FIPS_API = '%s'" % (self.get_5d_api()) table = 'GISCoreData.dbo.API_Regions_WM' polygon_WKT = queryWKT(table, where_clause) if polygon_WKT: poly = loads(polygon_WKT) _shapes['Api_region'] = poly #exctract section where_clause = "StateCode LIKE '%s' AND TWN LIKE '%s' AND TWNDIR LIKE '%s' AND RNG LIKE '%s' AND RNGDIR LIKE '%s'AND SECTION LIKE '%s'" % ( self.state_code, self.twnshp, self.twnshp_dir, self.range_, self.range_dir, self.section) table = 'GISCoreData.dbo.PLSS_SEC_%i' % self.mcode polygon_WKT = queryWKT(table, where_clause) if polygon_WKT: poly = loads(polygon_WKT) _shapes['Section'] = poly # qqsection if exists if self.qqsection: where_clause = "TWN LIKE '%s' AND TWNDIR LIKE '%s' AND RNG LIKE '%s' AND RNGDIR LIKE '%s'AND SECTION LIKE '%s' AND qqsection like '%s%s'" % ( self.twnshp, self.twnshp_dir, self.range_, self.range_dir, self.section, self.qsection, self.qqsection) table = 'GISCoreData.dbo.PLSS_QQ_%i' % self.mcode polygon_WKT = queryWKT(table, where_clause) if polygon_WKT: poly = loads(polygon_WKT) _shapes['qqSection'] = poly #TODO: add more conditions self.reference_shapes = _shapes
def coordinates(self): # variables self.twnshp = self.rec.geo.twnshp.strip() self.range_ = self.rec.geo.range_.strip() self.meridian = self.rec.geo.meridian.strip() self.section = self.rec.geo.section.strip() self.lsd = self.rec.geo.legal_subdivision.strip() if self.rec.geo.legal_subdivision else None self.qsection = self.rec.geo.qsection.strip() if self.rec.geo.qsection else None self.qqsection = self.rec.geo.qqsection.strip() if self.rec.geo.qqsection else None # self.offset_dir_1 = self.rec.geo.offset_dir_1.upper().strip() # self.offset_dir_2 = self.rec.geo.offset_dir_2.upper().strip() try: self.offset_1 = float(self.rec.geo.offset_1) self.offset_2 = float(self.rec.geo.offset_2) except: print '\tCould not convert offsets to float: %s, %s' % (self.rec.geo.offset_1, self.rec.geo.offset_2) self.legal_desc_str = '\tloc#: %s, uwi: %s, province: %s, meridian: %s, twn: %s, rng: %s, section: %s, lsd: %s, offset1: %s, offset2: %s' \ % (self.locnum, self.uwi, self.province_code, self.meridian, self.twnshp, self.range_, self.section, self.lsd, self.offset_1, self.offset_2) if not all([self.province_code, self.meridian, self.twnshp, self.range_, self.section, self.offset_1, self.offset_2]): # self.point is None, assigned in constructor return where_clause = "MER = '%s' AND TWN = %i AND RNG = %i AND SEC = %i" % (self.meridian, int(self.twnshp), int(self.range_), int(self.section)) table = 'GISCoreData.dbo.DLS_%s_SEC' % self.province_code wkt = queryWKT(table, where_clause) if not wkt: # self.point is None, assigned in constructor return # print wkt detector = CornerDetector(wkt) if detector.get_four_corners(): # directions are determined from the offset values. offset_dir_1 = 'FSL' if self.offset_1 > 0 else 'FNL' offset_dir_2 = 'FWL' if self.offset_2 > 0 else 'FEL' # print detector self.point = calc_point_from_offsets(detector.get_four_corners(), abs(self.offset_1), offset_dir_1, abs(self.offset_2), offset_dir_2, units='meters') else: print '\tunable to extract four corners from the referenced shape'
def coordinates(self): # variables self.abstract_no = self.rec.geo.abstract_number.strip() self.offset_dir_1 = self.rec.geo.offset_dir_1.upper().strip() self.offset_dir_2 = self.rec.geo.offset_dir_2.upper().strip() try: self.offset_1 = float(self.rec.geo.offset_1) self.offset_2 = float(self.rec.geo.offset_2) except: print '\tCould not convert offsets to float: %s, %s' % ( self.rec.geo.offset_1, self.rec.geo.offset_2) self.legal_desc_str = '\tloc#: %s, api: %s, state: %s, county: %s, abstract no: %s, offset1: %s, offsetDir1: %s, offset2: %s, offsetDir2: %s' \ % (self.locnum, self.api, self.state_code, self.county, self.abstract_no, self.offset_1, self.offset_dir_1, self.offset_2, self.offset_dir_2) # if data necessary for calculation is missing, return if not all([ self.county, self.abstract_no, self.offset_1, self.offset_2, self.offset_dir_1, self.offset_dir_2 ]): # self.point is None, assigned in constructor print '\tmissing crucial data in legal description to calculate the point location.' return where_clause = "COUNTY LIKE '%s' AND ANUM1 LIKE '%s'" % ( self.county, self.abstract_no) table = 'GISCoreData.dbo.TexasSurveys' wkt = queryWKT(table, where_clause) # at this point we skip records that have directions specified like FWSEL,... # or the polygon was not retreived if not wkt: # self.point is None, assigned in constructor print '\tCould not retrieve the referenced polygon based on query: %s' % where_clause return # print wkt detector = CornerDetector(wkt) if detector.get_four_corners(): # print detector self.point = calc_point_from_offsets(detector.get_four_corners(), self.offset_1, self.offset_dir_1, self.offset_2, self.offset_dir_2, units='feet') else: print '\tunable to extract four corners from the referenced shape'
def assign_ref_shapes(self): # dictionary that containes pairs rank: Polygon _shapes = {} # extract API region where_clause = "FIPS_API = '%s'" % (self.get_5d_api()) table = 'GISCoreData.dbo.API_Regions_WM' polygon_WKT = queryWKT(table, where_clause) if polygon_WKT: poly = loads(polygon_WKT) _shapes['Api_region'] = poly #exctract Abstract where_clause = "COUNTY = '%s' AND ANUM1 = '%s'" % (self.county.upper().strip(), self.abstract_no.strip()) table = 'GISCoreData.dbo.TexasSurveys' polygon_WKT = queryWKT(table, where_clause) if polygon_WKT: poly = loads(polygon_WKT) _shapes['Abstract'] = poly #TODO: add more conditions self.reference_shapes = _shapes
def coordinates(self): # variables self.map_sheet = self.rec.geo.map_sheet.strip() self.unit = self.rec.geo.unit.strip() self.quarter_unit = self.rec.geo.quarter_unit.strip() self.block = self.rec.geo.block.strip() # offset direction values are ignored # they are determined below from the negative or positive offset values try: self.offset_1 = float(self.rec.geo.offset_1) self.offset_2 = float(self.rec.geo.offset_2) except: print '\tCould not convert offsets to float: %s, %s' % (self.rec.geo.offset_1, self.rec.geo.offset_2) self.legal_desc_str = '\tloc#: %s, uwi: %s, province: %s, mapsheet: %s, block: %s, unit: %s, qunit: %s, offset_NS: %s, offset_EW: %s' \ % (self.locnum, self.uwi, self.province_code, self.map_sheet, self.block, self.unit, self.quarter_unit, self.offset_1, self.offset_2) if not all([self.province_code, self.map_sheet, self.block, self.unit, self.quarter_unit, self.offset_1, self.offset_2]): # self.point is None, assigned in constructor return where_clause = "MAPSHEET = '%s' AND BLOCK = '%s' AND UNIT = %i" % (self.map_sheet, self.block, int(self.unit)) table = 'GISCoreData.dbo.TS_%s_UNITS' % self.province_code wkt = queryWKT(table, where_clause) if not wkt: # self.point is None, assigned in constructor return # print wkt detector = CornerDetector(wkt) if detector.get_four_corners(): # directions are determined from the offset values. offset_dir_1 = 'FSL' if self.offset_1 > 0 else 'FNL' offset_dir_2 = 'FWL' if self.offset_2 > 0 else 'FEL' # the offset values are passed as positive values to the calc_point_from_offset funcion self.point = calc_point_from_offsets(detector.get_four_corners(), abs(self.offset_1), offset_dir_1, abs(self.offset_2), offset_dir_2, units='meters') else: print '\tunable to extract four corners from the referenced shape'
def coordinates(self): # variables self.abstract_no = self.rec.geo.abstract_number.strip() self.offset_dir_1 = self.rec.geo.offset_dir_1.upper().strip() self.offset_dir_2 = self.rec.geo.offset_dir_2.upper().strip() try: self.offset_1 = float(self.rec.geo.offset_1) self.offset_2 = float(self.rec.geo.offset_2) except: print '\tCould not convert offsets to float: %s, %s' % (self.rec.geo.offset_1, self.rec.geo.offset_2) self.legal_desc_str = '\tloc#: %s, api: %s, state: %s, county: %s, abstract no: %s, offset1: %s, offsetDir1: %s, offset2: %s, offsetDir2: %s' \ % (self.locnum, self.api, self.state_code, self.county, self.abstract_no, self.offset_1, self.offset_dir_1, self.offset_2, self.offset_dir_2) # if data necessary for calculation is missing, return if not all([self.county, self.abstract_no, self.offset_1, self.offset_2, self.offset_dir_1, self.offset_dir_2]): # self.point is None, assigned in constructor print '\tmissing crucial data in legal description to calculate the point location.' return where_clause = "COUNTY LIKE '%s' AND ANUM1 LIKE '%s'" % (self.county, self.abstract_no) table = 'GISCoreData.dbo.TexasSurveys' wkt = queryWKT(table, where_clause) # at this point we skip records that have directions specified like FWSEL,... # or the polygon was not retreived if not wkt: # self.point is None, assigned in constructor print '\tCould not retrieve the referenced polygon based on query: %s' % where_clause return # print wkt detector = CornerDetector(wkt) if detector.get_four_corners(): # print detector self.point = calc_point_from_offsets(detector.get_four_corners(), self.offset_1, self.offset_dir_1, self.offset_2, self.offset_dir_2, units='feet') else: print '\tunable to extract four corners from the referenced shape'
def coordinates(self): # variables self.twnshp = self.rec.geo.twnshp.strip() self.range_ = self.rec.geo.range_.strip() self.meridian = self.rec.geo.meridian.strip() self.section = self.rec.geo.section.strip() self.lsd = self.rec.geo.legal_subdivision.strip( ) if self.rec.geo.legal_subdivision else None self.qsection = self.rec.geo.qsection.strip( ) if self.rec.geo.qsection else None self.qqsection = self.rec.geo.qqsection.strip( ) if self.rec.geo.qqsection else None self.offset_dir_1 = self.rec.geo.offset_dir_1.upper().strip() self.offset_dir_2 = self.rec.geo.offset_dir_2.upper().strip() try: self.offset_1 = float(self.rec.geo.offset_1) self.offset_2 = float(self.rec.geo.offset_2) except: print '\tCould not convert offsets to float: %s, %s' % ( self.rec.geo.offset_1, self.rec.geo.offset_2) if not all([self.offset_dir_1, self.offset_dir_2]): raise DirectionException( "Wrong direction values: (%s, %s)" % (self.rec.geo.offset_dir_1.upper().strip(), self.rec.geo.offset_dir_2.upper().strip())) self.legal_desc_str = '\tloc#: %s, uwi: %s, province: %s, meridian: %s, twn: %s, rng: %s, section: %s, lsd: %s, offset1: %.2f, offset_dir1: %s, offset2: %.2f, offset_dir2: %s' \ % (self.locnum, self.uwi, self.province_code, self.meridian, self.twnshp, self.range_, self.section, self.lsd, self.offset_1, self.offset_dir_1, self.offset_2, self.offset_dir_2) if not all([ self.province_code, self.meridian, self.twnshp, self.range_, self.section, self.offset_1, self.offset_dir_1, self.offset_2, self.offset_dir_2 ]): # self.point is None, assigned in constructor return where_clause = "MER = '%s' AND TWN = '%s' AND RNG = '%s' AND SEC = '%s'" % ( self.meridian, self.twnshp, self.range_, self.section) table = 'GISCoreData.dbo.DLS_%s_SEC' % self.province_code wkt = queryWKT(table, where_clause) if not wkt: # self.point is None, assigned in constructor return # print wkt detector = CornerDetector(wkt) if detector.get_four_corners(): # print detector self.point = calc_point_from_offsets(detector.get_four_corners(), self.offset_1, self.offset_dir_1, self.offset_2, self.offset_dir_2, units='meters') else: print '\tunable to extract four corners from the referenced shape'
def coordinates(self): # variables self.mcode1 = self.rec.cty.mcode1 self.mcode2 = self.rec.cty.mcode2 self.mcode3 = self.rec.cty.mcode3 self.twnshp = self.rec.geo.twnshp.strip().zfill(3) self.twnshp_dir = self.rec.geo.twnshp_dir.upper().strip() self.range_ = self.rec.geo.range_.strip().zfill(3) self.range_dir = self.rec.geo.range_dir.upper().strip() self.section = self.rec.geo.section.strip().zfill(3) self.qsection = self.rec.geo.qsection.strip( ) if self.rec.geo.qsection else None self.qqsection = self.rec.geo.qqsection.strip( ) if self.rec.geo.qqsection else None self.offset_dir_1 = self.rec.geo.offset_dir_1.upper().strip() self.offset_dir_2 = self.rec.geo.offset_dir_2.upper().strip() try: self.offset_1 = float(self.rec.geo.offset_1) self.offset_2 = float(self.rec.geo.offset_2) except: print '\tCould not convert offsets to float: %s, %s' % ( self.rec.geo.offset_1, self.rec.geo.offset_2) # define the meridian zone if any([self.mcode2, self.mcode3]): self.mcode = meridian_zone(self.state_code, self.county, self.twnshp, self.twnshp_dir, self.range_, self.range_dir) else: self.mcode = self.mcode1 self.legal_desc_str = '\tloc#: %s, api: %s, state: %s, county: %s, mcode: %i, leg_desc: %s, twnshp: %s, twnshp_dir: %s, range: %s, range_dir: %s, section: %s, qsection: %s, qqsection: %s, offset1: %s, offsetDir1: %s, offset2: %s, offsetDir2: %s' \ % (self.locnum, self.api, self.state_code, self.county, self.mcode, self.legal_desc, self.twnshp, self.twnshp_dir, self.range_, self.range_dir, self.section, self.qsection, self.qqsection, self.offset_1, self.offset_dir_1, self.offset_2, self.offset_dir_2) if not all([ self.state_code, self.county, self.twnshp, self.twnshp_dir, self.range_, self.range_dir, self.section, self.offset_1, self.offset_2, self.offset_dir_1, self.offset_dir_2 ]): # self.point is None, assigned in constructor return where_clause = "StateCode LIKE '%s' AND TWN LIKE '%s' AND TWNDIR LIKE '%s' AND RNG LIKE '%s' AND RNGDIR LIKE '%s'AND SECTION LIKE '%s'" % ( self.state_code, self.twnshp, self.twnshp_dir, self.range_, self.range_dir, self.section) table = 'GISCoreData.dbo.PLSS_SEC_%i' % self.mcode wkt = queryWKT(table, where_clause) if not wkt or len(self.offset_dir_1) > 3 or len(self.offset_dir_2) > 3: # self.point is None, assigned in constructor return # print wkt detector = CornerDetector(wkt) if detector.get_four_corners(): # print detector self.point = calc_point_from_offsets(detector.get_four_corners(), self.offset_1, self.offset_dir_1, self.offset_2, self.offset_dir_2, units='feet') else: print '\tunable to extract four corners from the referenced shape'