ngageoint / hootenanny

Hootenanny conflates multiple maps into a single seamless map.
GNU General Public License v3.0
352 stars 74 forks source link

Refactor TranslationServer.js to make it testable by mocha #916

Closed brianhatchl closed 8 years ago

mattjdnv commented 8 years ago

Changes from today's conference call:

Example of thrown errors:

File that is junk:
<?xml version="1.0" encoding="UTF-8"?>
<osm version="0.6" generator="hootenanny" srs= [ Removed to save space ]>
    <node visible="true" id="-16" timestamp="1970-01-01T00:00:00Z" version="1" lat="34.5208745549100016" lon="69.4611927797299984"/>
    <node visible="true" id="-19" timestamp="1970-01-01T00:00:00Z" version="1" lat="34.4864509489500008" lon="69.5220985559899987"/>
    <way visible="true" id="-20" timestamp="1970-01-01T00:00:00Z" version="1">
        <nd ref="-16"/>
        <nd ref="-19"/>
        <tag k="mike" v="jeffe"/>
        <tag k="uuid" v="{39564280-a061-4024-b4f2-a2ac1f992476}"/>
    </way>
</osm>

Command:
echo "Junk to English"
hoot convert $HOOT_OPT -D "convert.ops=hoot::TranslationOp"  \
-D translation.script=$HOOT_HOME/translations/OSM_to_englishTDS61.js   \
junk.osm output_e61_junk.osm > to_e61_junk.txt

Result:
Junk to English
Error running convert:
Error: No Valid F_Code

Valid FCODE but invalid Geometry:
File:
<?xml version="1.0" encoding="UTF-8"?>
<osm version="0.6" generator="hootenanny" srs="[ Removed to save space ]">
    <node visible="true" id="-16" timestamp="1970-01-01T00:00:00Z" version="1" lat="34.5208745549100016" lon="69.4611927797299984"/>
    <node visible="true" id="-19" timestamp="1970-01-01T00:00:00Z" version="1" lat="34.4864509489500008" lon="69.5220985559899987"/>
    <way visible="true" id="-20" timestamp="1970-01-01T00:00:00Z" version="1">
        <nd ref="-16"/>
        <nd ref="-19"/>
        <tag k="aeroway" v="runway"/>
        <tag k="note" v="Papa Smurf"/>
        <tag k="uuid" v="{0bc545cd-cbe6-434a-99b5-026f46e575d6}"/>
    </way>
</osm>

Command: Same as for junk.osm but with runway.osm

Result:
Runway to English
Error running convert:
Error: Line geometry is not valid for GB055 in TDSv61

To/From english example

OSM File:
<?xml version="1.0" encoding="UTF-8"?>
<osm version="0.6" generator="hootenanny" srs="[ Removed to save space ]">
    <node visible="true" id="-16" timestamp="1970-01-01T00:00:00Z" version="1" lat="34.5208745549100016" lon="69.4611927797299984"/>
    <node visible="true" id="-19" timestamp="1970-01-01T00:00:00Z" version="1" lat="34.4864509489500008" lon="69.5220985559899987"/>
    <way visible="true" id="-20" timestamp="1970-01-01T00:00:00Z" version="1">
        <nd ref="-16"/>
        <nd ref="-19"/>
        <tag k="highway" v="primary"/>
        <tag k="note" v="Papa Smurf"/>
        <tag k="mike" v="jeffe"/>
        <tag k="uuid" v="{0bc545cd-cbe6-434a-99b5-026f46e575d6}"/>
    </way>
</osm>

To TDSv61 English:
23:50:26.160 INFO  ...p/hoot/core/cmd/ConvertCmd.cpp(  83) Converting road2.osm to output_e61_road2.osm...
23:50:26.161 INFO  .../hoot/core/cmd/BaseCommand.cpp(  78) Loading map data from road2.osm ...
23:50:26.162 INFO  .../cpp/hoot/core/ops/NamedOp.cpp(  56) Applying operation: hoot::TranslationOp
In Geometry: Line  In Element Type: 
In Tags: highway: :primary:
In Tags: mike: :jeffe:
In Tags: note: :Papa Smurf:
In Tags: uuid: :{0bc545cd-cbe6-434a-99b5-026f46e575d6}:
23:50:26.647 INFO  ...src/hoot/plugins/translate.js"( 382) "Column not found:: (mike=jeffe)"
TableName 0: ROAD_C  FCode: AP030  Geom: Line
Out Attrs:F_CODE: :AP030:
Out Attrs:RIN_ROI: :3:
Out Attrs:RTY: :3:
Out Attrs:UFI: :0bc545cd-cbe6-434a-99b5-026f46e575d6:
Out Attrs:ZI006_MEM: :Papa Smurf;<OSM>{"mike":"jeffe"}</OSM>:

eTableName 0: ROAD_C  FCode: AP030  Geom: Line
eOut Attrs:F_CODE: :AP030:
eOut Attrs:RIN_ROI: :3:
eOut Attrs:RTY: :3:
eOut Attrs:UFI: :0bc545cd-cbe6-434a-99b5-026f46e575d6:
eOut Attrs:ZI006_MEM: :Papa Smurf;<OSM>{"mike":"jeffe"}</OSM>:

Final Attrs:Feature Code: :AP030:Road:
Final Attrs:Note : Memorandum: :Papa Smurf;<OSM>{"mike":"jeffe"}</OSM>:
Final Attrs:Roadway Type: :Road:
Final Attrs:Route Identification <route designation type>: :National:
Final Attrs:Unique Entity Identifier: :0bc545cd-cbe6-434a-99b5-026f46e575d6:

23:50:26.691 INFO  ...p/hoot/core/cmd/ConvertCmd.cpp( 118) Convert operation took 0 sec

English TDSv61 to OSM:
23:50:26.832 INFO  ...p/hoot/core/cmd/ConvertCmd.cpp(  83) Converting output_e61_road2.osm to output_osm61_road2.osm...
23:50:26.834 INFO  .../hoot/core/cmd/BaseCommand.cpp(  78) Loading map data from output_e61_road2.osm ...
23:50:26.835 INFO  .../cpp/hoot/core/ops/NamedOp.cpp(  56) Applying operation: hoot::TranslationOp
In Attrs: Feature Code: :AP030:Road:
In Attrs: Note : Memorandum: :Papa Smurf;<OSM>{"mike":"jeffe"}</OSM>:
In Attrs: Roadway Type: :Road:
In Attrs: Route Identification <route designation type>: :National:
In Attrs: Unique Entity Identifier: :0bc545cd-cbe6-434a-99b5-026f46e575d6:
In Layername:   In Geometry: Line
In Attrs: F_CODE: :AP030:
In Attrs: RIN_ROI: :3:
In Attrs: RTY: :3:
In Attrs: UFI: :0bc545cd-cbe6-434a-99b5-026f46e575d6:
In Attrs: ZI006_MEM: :Papa Smurf;<OSM>{"mike":"jeffe"}</OSM>:
Out Tags: highway: :primary:
Out Tags: mike: :jeffe:
Out Tags: note: :Papa Smurf:
Out Tags: ref:road:class: :primary:
Out Tags: ref:road:type: :road:
Out Tags: uuid: :{0bc545cd-cbe6-434a-99b5-026f46e575d6}:

eOut Tags:highway: :primary:
eOut Tags:mike: :jeffe:
eOut Tags:note: :Papa Smurf:
eOut Tags:ref:road:class: :primary:
eOut Tags:ref:road:type: :road:
eOut Tags:uuid: :{0bc545cd-cbe6-434a-99b5-026f46e575d6}:

23:50:27.031 INFO  ...p/hoot/core/cmd/ConvertCmd.cpp( 118) Convert operation took 0 seconds