-- Script: add_point_properties_and_proximity.cypher -- Date: 2025-11-23 -- Description: Add point properties to existing nodes and create proximity relationships -- Add point properties to Organization nodes MATCH (o:Organization) WHERE o.latitude IS NOT NULL AND o.longitude IS NOT NULL SET o.location = point({latitude: o.latitude, longitude: o.longitude}); -- Add point properties to Site nodes MATCH (s:Site) WHERE s.latitude IS NOT NULL AND s.longitude IS NOT NULL SET s.location = point({latitude: s.latitude, longitude: s.longitude}); -- Create NEAR relationships for organizations within 5km MATCH (o1:Organization), (o2:Organization) WHERE o1.id < o2.id AND o1.location IS NOT NULL AND o2.location IS NOT NULL AND point.distance(o1.location, o2.location) < 5000 CREATE (o1)-[:NEAR { distance_m: point.distance(o1.location, o2.location), created_at: datetime() }]->(o2); -- Create NEAR relationships for sites within 5km MATCH (s1:Site), (s2:Site) WHERE s1.id < s2.id AND s1.location IS NOT NULL AND s2.location IS NOT NULL AND point.distance(s1.location, s2.location) < 5000 CREATE (s1)-[:NEAR { distance_m: point.distance(s1.location, s2.location), created_at: datetime() }]->(s2); -- Create SUPPLIES relationships from existing supply chain data (if any JSONB fields contain supplier info) -- Note: This would need to be adapted based on actual data structure -- Create COLLABORATES_WITH relationships from existing partnership data -- Note: This would need to be adapted based on actual data structure