agrobot_base/Python/cordenadas_offset.py

24 lines
7.7 KiB
Python

import json
# Substitua isso pelo seu JSON original
trajeto_json = {"features": [
{ "type": "Feature", "properties": { "Id": 1517, "Name": "Projeto", "Length": 21.724783283000001, "Dist1": 0.0, "Dist2": 0.0 }, "geometry": { "type": "LineString", "coordinates": [ [ -47.264037338109766, -22.339524535994332 ], [ -47.264017661846651, -22.339560540751183 ], [ -47.264008724140787, -22.339576970425245 ], [ -47.263999799939718, -22.339593449992105 ], [ -47.263990889109174, -22.339609979349202 ], [ -47.263981991515507, -22.339626558388819 ], [ -47.263973107023268, -22.339643187002231 ], [ -47.263964235496012, -22.33965986507852 ], [ -47.263943010772088, -22.339699942622605 ] ] } },
{ "type": "Feature", "properties": { "Id": 1517, "Name": "Projeto", "Length": 57.457315127000001, "Dist1": 0.0, "Dist2": 0.0 }, "geometry": { "type": "LineString", "coordinates": [ [ -47.264015055555213, -22.339505666408137 ], [ -47.264000672619751, -22.339531864331477 ], [ -47.263991696828107, -22.339548288742588 ], [ -47.263982734975592, -22.339564762798126 ], [ -47.263973786927508, -22.339581286395244 ], [ -47.263964852547424, -22.339597859430143 ], [ -47.263955931699435, -22.339614481793877 ], [ -47.263947024245901, -22.339631153376615 ], [ -47.263938130048174, -22.339647874066152 ], [ -47.263929248966853, -22.339664643747486 ], [ -47.26392038086145, -22.339681462303471 ], [ -47.263911525590025, -22.339698329615363 ], [ -47.263902683009505, -22.339715245562264 ], [ -47.263893852976231, -22.339732210019946 ], [ -47.263885035345169, -22.339749222862739 ], [ -47.263876229969412, -22.339766283963925 ], [ -47.263867436701474, -22.339783393193489 ], [ -47.263858655392752, -22.339800550419387 ], [ -47.263849885892363, -22.339817755509237 ], [ -47.263841128048647, -22.339835008327928 ], [ -47.263832381709157, -22.339852308737367 ], [ -47.263823646719999, -22.339869656597674 ], [ -47.263814922781556, -22.339887052055111 ], [ -47.263806203316406, -22.33990450781026 ], [ -47.263797473156359, -22.339922053442546 ], [ -47.263788722562197, -22.339939707172757 ], [ -47.263772441442221, -22.339972674804095 ] ] } },
{ "type": "Feature", "properties": { "Id": 1517, "Name": "Projeto", "Length": 117.746736119, "Dist1": 0.0, "Dist2": 0.0 }, "geometry": { "type": "LineString", "coordinates": [ [ -47.263992732508129, -22.339486780512566 ], [ -47.263974732054038, -22.339519567586802 ], [ -47.263965731813826, -22.339536036729378 ], [ -47.263956745814632, -22.339552555166417 ], [ -47.263947773919547, -22.339569122793812 ], [ -47.263938815989896, -22.339585739506486 ], [ -47.263929871887576, -22.339602405194356 ], [ -47.26392094147274, -22.339619119746359 ], [ -47.263912024604522, -22.339635883049215 ], [ -47.263903121141389, -22.339652694986722 ], [ -47.263894230940672, -22.339669555440707 ], [ -47.263885353858264, -22.339686464291287 ], [ -47.263876489748959, -22.339703421416548 ], [ -47.26386763846704, -22.339720426691283 ], [ -47.263858799865226, -22.339737479988795 ], [ -47.263849973794592, -22.339754581181339 ], [ -47.263841160105585, -22.339771730138086 ], [ -47.263832358647477, -22.33978892672588 ], [ -47.263823569267373, -22.339806170811546 ], [ -47.263814791811562, -22.339823462259098 ], [ -47.26380602612555, -22.339840800929505 ], [ -47.263797272053445, -22.339858186682097 ], [ -47.263788529295276, -22.33987561965904 ], [ -47.263779791344525, -22.33989311241416 ], [ -47.263771043198432, -22.339910694187278 ], [ -47.263762275217445, -22.339928382987218 ], [ -47.263753486223379, -22.339946179811562 ], [ -47.263744675637277, -22.339964084419481 ], [ -47.263735842867568, -22.339982096561368 ], [ -47.263726987310783, -22.340000215977238 ], [ -47.26371810834943, -22.340018442401146 ], [ -47.263709205353777, -22.34003677555744 ], [ -47.263700277681515, -22.340055215161392 ], [ -47.263691324675548, -22.340073760923875 ], [ -47.263681835699529, -22.34009347187321 ], [ -47.263672848858107, -22.340112192618236 ], [ -47.263663840017031, -22.340131007045898 ], [ -47.263654802943414, -22.3401499263258 ], [ -47.263645736917645, -22.340168950139933 ], [ -47.263636641211335, -22.340188078153293 ], [ -47.263627515078547, -22.340207310032113 ], [ -47.263618357760834, -22.340226645433351 ], [ -47.263609168486141, -22.340246084006974 ], [ -47.263599946467309, -22.340265625399184 ], [ -47.263590690904159, -22.340285269247953 ], [ -47.263581400981245, -22.340305015187877 ], [ -47.26357207586976, -22.340324862845815 ], [ -47.263562714727399, -22.340344811841895 ], [ -47.263553316694953, -22.340364861795894 ], [ -47.263543880900556, -22.34038501231867 ], [ -47.263534406459335, -22.340405263013295 ], [ -47.263524892468752, -22.34042561348399 ], [ -47.263512882925042, -22.340451318065195 ] ] } },
{ "type": "Feature", "properties": { "Id": 1517, "Name": "Projeto", "Length": 117.746736172, "Dist1": 0.0, "Dist2": 0.0 }, "geometry": { "type": "LineString", "coordinates": [ [ -47.263992732508122, -22.339486780512566 ], [ -47.263974732054038, -22.339519567586802 ], [ -47.263965731813826, -22.339536036729378 ], [ -47.263956745814632, -22.339552555166417 ], [ -47.263947773919547, -22.339569122793812 ], [ -47.263938815989917, -22.339585739506493 ], [ -47.263929871887576, -22.339602405194348 ], [ -47.26392094147274, -22.339619119746359 ], [ -47.263912024604522, -22.339635883049215 ], [ -47.263903121141389, -22.339652694986722 ], [ -47.263894230940672, -22.339669555440707 ], [ -47.263885353858264, -22.339686464291287 ], [ -47.263876489748959, -22.339703421416548 ], [ -47.26386763846704, -22.339720426691297 ], [ -47.263858799865226, -22.339737479988777 ], [ -47.263849973794592, -22.339754581181353 ], [ -47.263841160105585, -22.339771730138086 ], [ -47.263832358647477, -22.33978892672588 ], [ -47.263823569267373, -22.339806170811563 ], [ -47.263814791811562, -22.339823462259098 ], [ -47.26380602612555, -22.339840800929505 ], [ -47.263797272053445, -22.339858186682097 ], [ -47.263788529295276, -22.33987561965905 ], [ -47.263779791344525, -22.33989311241416 ], [ -47.263771043198432, -22.339910694187278 ], [ -47.263762275217445, -22.339928382987242 ], [ -47.263753486223379, -22.339946179811562 ], [ -47.263744675637277, -22.339964084419481 ], [ -47.263735842867568, -22.339982096561368 ], [ -47.263726987310783, -22.340000215977238 ], [ -47.26371810834943, -22.340018442401156 ], [ -47.263709205353784, -22.340036775557447 ], [ -47.263700277681515, -22.340055215161392 ], [ -47.263691324675548, -22.340073760923875 ], [ -47.263681829429849, -22.340093484896855 ], [ -47.263672848187824, -22.340112194014417 ], [ -47.263663839410441, -22.340131008312643 ], [ -47.263654802396871, -22.340149927469991 ], [ -47.263645736427542, -22.340168951168298 ], [ -47.26363664077423, -22.340188079072526 ], [ -47.263627514690995, -22.340207310848786 ], [ -47.263618357419503, -22.340226646153983 ], [ -47.263609168187827, -22.340246084637961 ], [ -47.263599946208856, -22.340265625946845 ], [ -47.263590690682427, -22.340285269718571 ], [ -47.263581400793178, -22.3403050155876 ], [ -47.263572075712418, -22.340324863180712 ], [ -47.263562714597846, -22.340344812117923 ], [ -47.26355331659034, -22.340364862019008 ], [ -47.263543880818155, -22.340385012494718 ], [ -47.26353440639631, -22.340405263147982 ], [ -47.263524892422467, -22.340425613583026 ], [ -47.263512882924815, -22.340451318065618 ] ] } }
]}
offset_latitude = 0.0000102 # Aproximadamente 75cm em latitude
offset_longitude = 0.0000102 # Aproximadamente 75cm em longitude, simplificação
# Aplicar offset a cada coordenada
for feature in trajeto_json['features']:
for i, coord in enumerate(feature['geometry']['coordinates']):
# Aplicando o offset
coord[0] += offset_longitude # Longitude
coord[1] += offset_latitude # Latitude
# Convertendo o objeto modificado de volta para JSON
trajeto_json_modificado = json.dumps(trajeto_json)
print(trajeto_json_modificado)