From a geoID? I don't know. I mean, I guess you could roughly calculate, but those numbers are only to within 2 meters (one square) and each TerID is 500x500 squares making each TerID 1km^2 and the entire map 3km^2...
so assuming 250, 250 in terid 446 is 0,0 and 1,1 in 242 is -1500,1500, that'd be... x-250, y-250... ya know what, screw it. I'll just make an sql proc.
- Code: Select all
DELIMITER |
CREATE PROCEDURE `p_WorldCoordsFromGeoID`(IN `GeoID` INT UNSIGNED)
LANGUAGE SQL
NOT DETERMINISTIC
CONTAINS SQL
SQL SECURITY DEFINER
COMMENT ''
BEGIN
DECLARE worldX, worldY BIGINT;
select
(geoID >> 18) as terID,
(geoID & ((1 << 9) - 1)) as `x`,
((geoID >> 9) & ((1 << (9)) - 1)) as `y` INTO @terID,worldX,worldY;
SET worldX = worldX * 2 - 500;
SET worldY = worldY * -2 + 500;
CASE @terID
WHEN 442 THEN BEGIN
SET worldX = worldX - 1000;
SET worldY = worldY + 1000;
END;
WHEN 443 THEN BEGIN
SET worldY = worldY + 1000;
END;
WHEN 444 THEN BEGIN
SET worldX = worldX + 1000;
SET worldY = worldY + 1000;
END;
WHEN 445 THEN BEGIN
SET worldX = worldX + 1000;
END;
WHEN 446 THEN BEGIN END;
WHEN 447 THEN BEGIN
SET worldX = worldX + 1000;
END;
WHEN 448 THEN BEGIN
SET worldX = worldX - 1000;
SET worldY = worldY - 1000;
END;
WHEN 449 THEN BEGIN
SET worldY = worldY - 1000;
END;
WHEN 448 THEN BEGIN
SET worldX = worldX + 1000;
SET worldY = worldY - 1000;
END;
END CASE;
SELECT worldX, worldY;
END|