Esempio n. 1
0
def manualtest_ilismeta_from_xtf():
    loader = ModelLoader(
        "./tests/data/ch.bazl/ch.bazl.sicherheitszonenplan.oereb_20131118.xtf")
    outfile = loader.create_ilismeta_model()
    with open(outfile) as file:
        imd = file.read()
        assert '<IlisMeta07.ModelData.Class TID="OeREBKRM09trsfr.Transferstruktur.ZustaendigeStelleGeometrie">' in imd
Esempio n. 2
0
def manualtest_ilismeta_from_xtf():
    loader = ModelLoader(
        "./tests/data/ch.bazl/ch.bazl.sicherheitszonenplan.oereb_20131118.xtf")
    outfile = loader.create_ilismeta_model()
    with open(outfile) as file:
        imd = file.read()
        assert '<IlisMeta07.ModelData.Class TID="OeREBKRM09trsfr.Transferstruktur.ZustaendigeStelleGeometrie">' in imd
Esempio n. 3
0
def test_detect_models_ili2():
    loader = ModelLoader("./tests/data/ch.bazl/ch.bazl.sicherheitszonenplan.oereb_20131118.xtf")
    models = loader.detect_models()
    names = map(lambda model: model.name, models)
    assert names == [
        "CodeISO", "chGeoId10", "MultilingualText09", "OeREBKRM09", "OeREBKRM09vs", "OeREBKRM09trsfr"]
    assert models[0].version == "20060808"
    assert models[0].uri == "http://www.kogis.ch"
Esempio n. 4
0
def test_detect_models_ili2():
    loader = ModelLoader(
        "./tests/data/ch.bazl/ch.bazl.sicherheitszonenplan.oereb_20131118.xtf")
    models = loader.detect_models()
    names = map(lambda model: model.name, models)
    assert set(names) == {'OeREBKRM09trsfr', 'MultilingualText09', 'chGeoId10', 'CodeISO', 'OeREBKRM09vs', 'OeREBKRM09'}
    assert models[0].version == "20060808"
    assert models[0].uri == "http://www.kogis.ch"
Esempio n. 5
0
 def on_mCreateIlisMetaButton_clicked(self):
     loader = ModelLoader("")
     outfile = QFileDialog.getSaveFileName(
         None, "Save File", self.ui.mIliLineEdit.text(),
         "IlisMeta model (*.imd *.IMD)")
     if not outfile:
         return
     os.environ['ILI2C'] = self.ui.mIli2cLineEdit.text()
     ret = loader.convert_model([self.ui.mIliLineEdit.text()], outfile)
     err = ("Error:" in ret)
     self._show_log_window()
     self._log_output("IlisMeta creation: " + str(ret))
     if not err:
         self.ui.mModelLineEdit.setText(outfile)
Esempio n. 6
0
def manualtest_model_conversion():
    loader = ModelLoader("")
    outfile = os.path.join(TEMPDIR, "tmpogrtools")
    loader.convert_model(["./tests/data/ili/Beispiel.ili"], outfile)
    with open(outfile) as file:
        imd = file.read()
        assert 'IlisMeta07.ModelData.EnumNode TID="Beispiel.Bodenbedeckung.BoFlaechen.Art.TYPE.TOP"' in imd

    loader.convert_model(["./tests/data/ili/Test23_erweitert.ili"], outfile)
    with open(outfile) as file:
        imd = file.read()
        assert 'IlisMeta07.ModelData.Class TID="Test23_erweitert.FixpunkteKategorie1.LFP1"' in imd
        # Does include Test23.ili as well:
        assert 'IlisMeta07.ModelData.NumType TID="Test23.Genauigkeit"' in imd
Esempio n. 7
0
 def on_mModelLookupButton_clicked(self):
     imd = None
     try:
         loader = ModelLoader(self.ui.mDataLineEdit.text())
         ili = loader.gen_lookup_ili()
         qDebug(ili)
         wpsreq = self._create_wps_request(ili)
         req = urllib2.Request(url="http://wps.sourcepole.ch/wps?",
                               data=wpsreq,
                               headers={'Content-Type': 'application/xml'})
         #TODO: proxy support
         response = urllib2.urlopen(req)  # timeout=int(TIMEOUT)
         result = response.read()
         imd = self._parse_wps_response(result)
     except urllib2.HTTPError, err:
         qDebug("HTTPError %d" % err.code)
Esempio n. 8
0
 def on_mModelLookupButton_clicked(self):
     imd = None
     try:
         loader = ModelLoader(self.ui.mDataLineEdit.text())
         models = loader.detect_models()
         model_names = map(lambda m: m.name, models)
         self._log_output("Looking up models: " + ', '.join(model_names))
         ili = loader.gen_lookup_ili()
         qDebug(ili)
         wpsreq = self._create_wps_request(ili)
         req = urllib2.Request(url="http://wps.sourcepole.ch/wps?",
                               data=wpsreq,
                               headers={'Content-Type': 'application/xml'})
         # TODO: proxy support
         response = urllib2.urlopen(req)  # timeout=int(TIMEOUT)
         result = response.read()
         imd = self._parse_wps_response(result)
     except urllib2.HTTPError, err:
         qDebug("HTTPError %d" % err.code)
Esempio n. 9
0
    def loadModel(self):
        imd = None
        try:
            loader = ModelLoader(self.ui.mDataLineEdit.text())
            models = loader.detect_models()
            model_names = map(lambda m: m.name, models)
            self._log_output("Looking up models: " + ', '.join(model_names))
            ili = loader.gen_lookup_ili()
            qDebug(ili)
            wpsreq = self._create_wps_request(ili)
            url = self.ui.mIlisMetaUrlLineEdit.text()
            req = QNetworkRequest(QtCore.QUrl(url))
            req.setHeader(QNetworkRequest.ContentTypeHeader, 'application/xml')
            reply = QgsNetworkAccessManager.instance().post(req, wpsreq)

            # Wait for reply or timeout
            loop = QEventLoop()
            reply.finished.connect(loop.quit)
            QTimer.singleShot(15000, reply.abort)
            loop.exec_()

            if reply.isFinished() and reply.error() == QNetworkReply.NoError:
                result = reply.readAll()
                imd = self._parse_wps_response(result)
        except:
            qDebug("Exception during IlisModel download")
        if imd is None:
            self._show_log_window()
            QgsMessageLog.logMessage(
                "Couldn't download Ilismeta model", "Interlis",
                QgsMessageLog.WARNING)
            self.ui.mModelLineEdit.setText("")
        else:
            fh, imdfn = tempfile.mkstemp(suffix='.imd')
            os.close(fh)
            with codecs.open(imdfn, "w", encoding='utf-8') as file:
                file.write(imd)
            self.ui.mModelLineEdit.setText(imdfn)
Esempio n. 10
0
def manualtest_model_conversion():
    loader = ModelLoader("")
    outfile = os.path.join(TEMPDIR, "tmpogrtools")
    loader.convert_model(["./tests/data/ili/Beispiel.ili"], outfile)
    with open(outfile) as file:
        imd = file.read()
        assert 'IlisMeta07.ModelData.EnumNode TID="Beispiel.Bodenbedeckung.BoFlaechen.Art.TYPE.TOP"' in imd

    loader.convert_model(["./tests/data/ili/Test23_erweitert.ili"], outfile)
    with open(outfile) as file:
        imd = file.read()
        assert 'IlisMeta07.ModelData.Class TID="Test23_erweitert.FixpunkteKategorie1.LFP1"' in imd
        # Does include Test23.ili as well:
        assert 'IlisMeta07.ModelData.NumType TID="Test23.Genauigkeit"' in imd
Esempio n. 11
0
def test_detect_ili1():
    loader = ModelLoader("./tests/data/ili/Beispiel.itf")
    assert loader.detect_format() == 'Interlis 1'
Esempio n. 12
0
def test_detect_ili1():
    loader = ModelLoader("./tests/data/ili/Beispiel.itf")
    assert loader.detect_format() == 'Interlis 1'
Esempio n. 13
0
def test_detect_ili2():
    loader = ModelLoader(
        "./tests/data/ch.bazl/ch.bazl.sicherheitszonenplan.oereb_20131118.xtf")
    assert loader.detect_format() == 'Interlis 2'
Esempio n. 14
0
def test_lookup_ili():
    loader = ModelLoader("./tests/data/ili/roads23.xtf")
    assert "IMPORTS RoadsExdm2ben" in loader.gen_lookup_ili()
Esempio n. 15
0
def test_detect_models_ili1():
    loader = ModelLoader("./tests/data/ili/Beispiel.itf")
    assert loader.detect_models()[0].name == 'Beispiel'
Esempio n. 16
0
def test_detect_models_none():
    loader = ModelLoader("./tests/data/osm/railway.shp")
    assert loader.detect_models() is None
Esempio n. 17
0
def test_detect_models_ili1():
    loader = ModelLoader("./tests/data/ili/Beispiel.itf")
    assert loader.detect_models()[0].name == 'Beispiel'
Esempio n. 18
0
def test_detect_ili2():
    loader = ModelLoader(
        "./tests/data/ch.bazl/ch.bazl.sicherheitszonenplan.oereb_20131118.xtf")
    assert loader.detect_format() == 'Interlis 2'
Esempio n. 19
0
def test_detect_models_none():
    loader = ModelLoader("./tests/data/osm/railway.shp")
    assert loader.detect_models() is None
Esempio n. 20
0
def test_lookup_ili():
    loader = ModelLoader("./tests/data/ili/roads23.xtf")
    assert "IMPORTS RoadsExdm2ben" in loader.gen_lookup_ili()