'''

@author: olivier.massot, 2018
'''
from core import mn
from core.gis_ import Datasource


ds = Datasource(r"C:\dev\python\datacheck\work\STURNO_178AP1_REC_171121_OK\NOEUD_GEO.shp")
layer = ds.layer
noeuds = [f for f in ds.layer]

ant_db = mn.ANTDb_0()

for noeud in noeuds:
    
    sql = """Select z.ID_FTTH_MN_GR_NOEUD_GEO FROM SIG_ANT.FTTH_MN_GR_NOEUD_GEO z 
                WHERE z.NO_NOM='{}' 
               AND SDO_GEOM.SDO_DISTANCE(z.GEOMETRY, SDO_GEOMETRY(2001, 3949, SDO_POINT_TYPE({}, {}, NULL), NULL, NULL),0.005)>10;
               """.format(noeud.NO_NOM, noeud.geom.GetX(), noeud.geom.GetY())
               
query = ant_db.read(sql)

for row in query:
    print(row)
    break