0

I use Python and FME. I would like to use a transformer "KMLRegionSetter_2" for KML file. I use a fmi file for the transformation.

reader=FMEReader("OGCKML",{'USER_PIPELINE':"C:\\arcfactory.fmi"})
                    reader.open("repertoryofkml","") ***Is it correct ?***
                    log.log("Reader opened")

                    writer=FMEWriter("OGCKML")
                    writer.open(repertoryofkml+"_region.kml")
                    schemaFeature=FMEFeature()
                    log.log("Copying schema features")
                    while reader.readSchema(schemaFeature):
                        log.logFeature(schemaFeature)
                        writer.addSchema(schemaFeature)
                    feature=FMEFeature()
                    while reader.read(feature):
                        log.logFeature(feature)
                        writer.write(feature)
                    reader.close()
                    writer.close()
                    log.log("Translation completed.")

The arcfactory is

    DEFAULT_MACRO WB_CURRENT_CONTEXT
# -------------------------------------------------------------------------
# The region extent is set to be  
# calculated based on the extent   
#  of incoming features.
Tcl2 proc KMLRegionSetter_2_bounding_box_setter { minx maxx miny maxy} { \
    if { [string compare {Yes} {Yes}]==0 } {                           \
      global FME_CoordSys;                                             \
      if { [string length $FME_CoordSys]>0 } {                         \
         FME_Execute Bounds kml_latlonaltbox_west kml_latlonaltbox_east kml_latlonaltbox_south kml_latlonaltbox_north; \
          FME_Execute Reproject \"$FME_CoordSys\" LL84 kml_latlonaltbox_west kml_latlonaltbox_south; \
          FME_Execute Reproject \"$FME_CoordSys\" LL84 kml_latlonaltbox_east kml_latlonaltbox_north; \
       } else {                                                        \
          FME_LogMessage fme_warn \"KMLRegionSetter: A valid coordinate system is required for calculating the region\'s bounding box\"; \
       }                                                               \
    } else {                                                           \
       FME_SetAttribute kml_latlonaltbox_west \"$minx\";               \
       FME_SetAttribute kml_latlonaltbox_east \"$maxx\";               \
       FME_SetAttribute kml_latlonaltbox_south \"$miny\";              \
       FME_SetAttribute kml_latlonaltbox_north \"$maxy\";              \
    }                                                                  \
}

FACTORY_DEF * TeeFactory                                               \
   FACTORY_NAME KMLRegionSetter_2                                      \
   INPUT  FEATURE_TYPE BoundingBoxAccumulator_BOUNDING_BOX             \
   OUTPUT FEATURE_TYPE KMLRegionSetter_2_OUTPUT                        \
           kml_lod_min_lod_pixels "1500"                               \
            kml_lod_max_lod_pixels "-1"                                \
            kml_lod_min_fade_extent  "0"                               \
            kml_lod_max_fade_extent "0"                                \
            @Log("Before")                                             \
        @Tcl2("KMLRegionSetter_2_bounding_box_setter {<Unused>} {<Unused>} {<Unused>} {<Unused>} ")
        @Log("After")                                              \

Is there a way I can find out if the product is correct?

2
  • 1
    A first point of call is to find out: Does it work?
    – Hairy
    Jan 19, 2012 at 13:22
  • I find the first block of code intriguing. How is it that you are making a call to a reader from Python? How do you know the syntax? Where is this API? SWIG, ctypes, or comtypes? Nov 6, 2013 at 0:39

1 Answer 1

1

I just want to make sure you know about the IFMEWorkspaceRunner interface in our API.

I look at what you are doing and can't help but wonder if it would be quicker to use the KMLRegionSetter in Workbench, and just run it programmatically.

Anyway, just a thought.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.