Lisez, transformez et écrivez des données géographiques dans vos jobs : shapefiles, PostGIS, WFS, projections, calculs géométriques. Les composants Talend Spatial, portés vers Java 21 et GeoTools 35, sont livrés avec Talaxie. Read, transform and write geographic data in your jobs: shapefiles, PostGIS, WFS, projections, geometric calculations. The Talend Spatial components, ported to Java 21 and GeoTools 35, ship with Talaxie.
L'extension Talend Spatial (licence Apache 2.0) ajoutait au Studio des composants géospatiaux, un type de colonne Geometry et des routines. Elle reposait sur GeoTools 8.5, qui ne démarre plus après Java 8. Talaxie livre une version portée vers Java 21, GeoTools 35.2 et JTS 1.20 : rien à installer, les composants sont dans la palette.
The Talend Spatial extension (Apache 2.0 license) added geospatial components, a Geometry column type and routines to the Studio. It relied on GeoTools 8.5, which no longer starts after Java 8. Talaxie ships a version ported to Java 21, GeoTools 35.2 and JTS 1.20: nothing to install, the components are in the palette.
Famille Geo et ses sous-familles : fichiers, base de données, calculs, manipulations, opérateurs géométriques, collecteurs, qualité, géocodage, métadonnées. Les composants ont l'onglet Composant, l'ajout rapide et la recherche comme ceux de Talaxie. Geo family and its sub-families: files, database, calculators, manipulators, geometric operators, collectors, data quality, geocoding, metadata. The components have the Component tab, quick add and search like the Talaxie ones.
Proposé dans la liste des types de tous les schémas (id_Geometry). Une colonne Geometry passe d'un composant à l'autre comme une colonne ordinaire, tMap et tLogRow compris.
Offered in the type list of every schema (id_Geometry). A Geometry column goes from one component to the next like any column, tMap and tLogRow included.
GeometryOperation, GeoOperation, GeometryUtility et OpenStreetMap, utilisables dans toute expression. Une routine n'est jointe qu'au job qui la cite, avec ses bibliothèques.
GeometryOperation, GeoOperation, GeometryUtility and OpenStreetMap, usable in any expression. A routine is only added to the job that uses it, with its libraries.
https://repo.osgeo.org/repository/release (GeoTools n'est pas sur Maven Central). Le poste doit alors accéder à ces dépôts, directement ou par un miroir.
The libraries (GeoTools, JTS, PostgreSQL driver…) are not shipped: Talaxie takes them from the local Maven repository, otherwise downloads them on the first run from Maven Central and https://repo.osgeo.org/repository/release (GeoTools is not on Maven Central). The machine then needs access to these repositories, directly or through a mirror.
CREATE EXTENSION postgis; dans la base).
For the PostGIS components: PostgreSQL with the PostGIS extension (CREATE EXTENSION postgis; in the database).
Une colonne de type Geometry contient un objet org.talend.sdi.geometry.Geometry : une géométrie JTS (point, ligne, polygone, collection) et, éventuellement, son système de coordonnées (CRS). Son texte est le WKT de la géométrie : un tLogRow affiche POINT (2.35 48.85).
A Geometry column holds an org.talend.sdi.geometry.Geometry object: a JTS geometry (point, line, polygon, collection) and, optionally, its coordinate reference system (CRS). Its text is the geometry WKT: a tLogRow prints POINT (2.35 48.85).
Depuis un texte WKT, dans un tFixedFlowInput, un tMap ou un tJavaRow : From a WKT text, in a tFixedFlowInput, a tMap or a tJavaRow:
org.talend.sdi.geometry.Geometry.parseGeometry("POINT (2.35 48.85)")
org.talend.sdi.geometry.Geometry.parseGeometry("POLYGON ((0 0, 2 0, 2 2, 0 2, 0 0))")
Ou avec le composant sGeomTxtInput, qui produit une ligne à partir d'un WKT, et les composants de lecture (shapefile, PostGIS, WFS).
Or with the sGeomTxtInput component, which produces one row from a WKT, and the reading components (shapefile, PostGIS, WFS).
POINT (2.35 48.85) est Paris en WGS 84 (EPSG:4326).
The order is always x = longitude, y = latitude: POINT (2.35 48.85) is Paris in WGS 84 (EPSG:4326).
"EPSG:2154" pour le Lambert 93). La base EPSG de GeoTools est livrée avec les bibliothèques : aucun accès réseau n'est nécessaire.
Systems are given by their EPSG code ("EPSG:2154" for Lambert 93). The GeoTools EPSG database comes with the libraries: no network access is needed.
setCRS("EPSG:4326"), getCRS(), getSRID() et getEPSG() lisent ou fixent le système d'une géométrie.
setCRS("EPSG:4326"), getCRS(), getSRID() and getEPSG() read or set the system of a geometry.
| getArea() · getLength() · distance(g) | Surface, longueur, distance, dans l'unité du système de coordonnées.Area, length, distance, in the unit of the coordinate system. |
| buffer(d) · convexHull() · getCentroid() · getInteriorPoint() · getEnvelope() · getBoundary() | Géométries dérivées ; le système de coordonnées est conservé.Derived geometries; the coordinate system is kept. |
| union(g) · intersection(g) · difference(g) · symDifference(g) | Opérations ensemblistes.Set operations. |
| intersects(g) · contains(g) · within(g) · touches(g) · crosses(g) · overlaps(g) · covers(g) · coveredBy(g) · disjoint(g) · relate(g) | Prédicats spatiaux (modèle DE-9IM).Spatial predicates (DE-9IM model). |
| getGeometryType() · getNumPoints() · getNumGeometries() · getGeometryN(n) · getCoordinates() · isValid() · isEmpty() | Description de la géométrie.Geometry description. |
| simplify(type, tolérance) | Simplification : "DouglasPeuckerSimplifier" ou "TopologyPreservingSimplifier".Simplification: "DouglasPeuckerSimplifier" or "TopologyPreservingSimplifier". |
| _getInternalGeometry() | La géométrie JTS (org.locationtech.jts.geom.Geometry), pour tout ce que JTS sait faire.The JTS geometry (org.locationtech.jts.geom.Geometry), for anything JTS can do. |
Une colonne Geometry correspond au type GEOMETRY de PostgreSQL (PostGIS) et à MDSYS.SDO_GEOMETRY ou SDO_GEOMETRY d'Oracle.
A Geometry column maps to the PostgreSQL (PostGIS) GEOMETRY type and to Oracle MDSYS.SDO_GEOMETRY or SDO_GEOMETRY.
Le code d'un job nomme la classe Geometry sans son paquet. Les composants Spatial qui lisent ou calculent des géométries ajoutent l'import. Dans un job où une colonne Geometry ne passe par aucun d'eux, ajoutez import org.talend.sdi.geometry.Geometry; dans l'onglet Paramètres avancés › Import d'un tJava.
Job code names the Geometry class without its package. The Spatial components that read or compute geometries add the import. In a job where a Geometry column goes through none of them, add import org.talend.sdi.geometry.Geometry; in the Advanced settings › Import tab of a tJava.
Par famille de la palette. Les composants marqués non porté sont livrés tels quels, sans portage ; web appelle un service en ligne ; bac à sable vient du plugin expérimental de Talend Spatial. By palette family. Components marked not ported ship as they were, without porting; web calls an online service; sandbox comes from the experimental Talend Spatial plugin.
| FamilleFamily | ComposantComponent | Description |
|---|---|---|
| Geo/File/Input | sShapefileInput | Lit un fichier ESRI Shapefile, objet par objet.Reads an ESRI Shapefile, feature by feature. |
| sWfsInput | Lit les objets d'un serveur WFS (versions 1.0.0, 1.1.0, 2.0.0).Reads the features of a WFS server (versions 1.0.0, 1.1.0, 2.0.0). | |
| sGeomTxtInput | Crée un objet à partir de sa représentation WKT.Creates a feature from its WKT representation. | |
| sOSMNodesInput · sOSMWaysInput | Lit un fichier OpenStreetMap et en extrait les nœuds ou les chemins (famille Geo/File/Input/OpenStreetMap).Reads an OpenStreetMap file and extracts its nodes or ways (Geo/File/Input/OpenStreetMap family). | |
| sOgrInput non porténot ported | Lit une source vecteur par GDAL/OGR.Reads a vector source through GDAL/OGR. | |
| sOGRInfoInput non porténot ported | Informations sur un jeu de données vecteur (GDAL/OGR).Information about a vector dataset (GDAL/OGR). | |
| sGdalInfoInput non porténot ported | Informations sur un jeu de données raster (GDAL).Information about a raster dataset (GDAL). | |
| sNetCDFInput · sOPeNDAPInput bac à sablesandbox | Une ligne par combinaison d'index d'un fichier NetCDF ou d'une source OPeNDAP.One row per index combination of a NetCDF file or an OPeNDAP source. | |
| Geo/File/Output | sShapefileOutput | Écrit un fichier ESRI Shapefile (avec option de métadonnées ISO 19139).Writes an ESRI Shapefile (with an ISO 19139 metadata option). |
| sGeoRSSOutput | Écrit un flux GeoRSS (GeoRSS simple ou point GML) ; chaque colonne donne l'élément de même nom (title…).Writes a GeoRSS feed (simple GeoRSS or GML point); each column gives the element of the same name (title…). | |
| sOgrOutput non porténot ported | Écrit une source vecteur par GDAL/OGR.Writes a vector source through GDAL/OGR. | |
| Geo/File/Management | sGeoServerPublisher bac à sablesandbox | Publie un shapefile zippé ou un GeoTIFF sur un GeoServer.Publishes a zipped shapefile or a GeoTIFF to a GeoServer. |
| sThreddsIterator bac à sablesandbox | Une ligne par jeu de données accessible d'un catalogue THREDDS.One row per accessible dataset of a THREDDS catalog. | |
| Geo/Database | sPostgisInput | Lit une table PostGIS, objet par objet.Reads a PostGIS table, feature by feature. |
| sPostgisOutput | Écrit une table PostGIS : la table est supprimée puis recréée.Writes a PostGIS table: the table is dropped then recreated. | |
| Geo/Calculators | sAreaCalculator | Surface de la géométrie (colonne area).Geometry area (area column). |
| sLengthCalculator | Longueur de la géométrie.Geometry length. | |
| sPointsCounter · sGeomsCounter | Nombre de points, nombre de géométries simples.Number of points, number of simple geometries. | |
| sGetGeomSRID | SRID de chaque géométrie, dans une nouvelle colonne.SRID of each geometry, in a new column. | |
| sCoordinateFetcher | Coordonnées x et y du point d'index donné, dans de nouvelles colonnes.x and y coordinates of the point at the given index, in new columns. | |
| sDecimalDegreesCalculator | Degrés décimaux à partir de degrés, minutes et secondes rangés dans des colonnes séparées.Decimal degrees from degrees, minutes and seconds stored in separate columns. | |
| sGetElevation web | Altitude d'un point (GeoNames, données GTOPO30 ou SRTM).Elevation of a point (GeoNames, GTOPO30 or SRTM datasets). | |
| Geo/Manipulators | sBufferCalculator | Zone tampon, de distance positive ou négative.Buffer, with a positive or negative distance. |
| sCentroidCalculator | Centroïde.Centroid. | |
| sInsidePointExtractor | Point garanti à l'intérieur de la surface.Point guaranteed to lie inside the area. | |
| sEnvelopeCalculator | Enveloppe (rectangle englobant).Envelope (bounding rectangle). | |
| sConvexHullCalculator | Enveloppe convexe.Convex hull. | |
| sBoundaryReplacer | Remplace un polygone par sa limite (une ligne) ; points et lignes inchangés.Replaces a polygon with its boundary (a line); points and lines unchanged. | |
| s2DPointReplacer | Remplace la géométrie par un point dont X et Y viennent de deux colonnes.Replaces the geometry with a point whose X and Y come from two columns. | |
| sChangeLineDirection | Inverse le sens des lignes.Reverses line direction. | |
| sSimplify | Simplification (Douglas-Peucker ou préservation de la topologie), selon une tolérance.Simplification (Douglas-Peucker or topology preserving), with a tolerance. | |
| sTransform | Transformation affine : translation, rotation, mise à l'échelle.Affine transformation: translation, rotation, scaling. | |
| sSimpleGeomToMulti | POINT, LINESTRING, POLYGON → MULTIPOINT, MULTILINESTRING, MULTIPOLYGON.POINT, LINESTRING, POLYGON → MULTIPOINT, MULTILINESTRING, MULTIPOLYGON. | |
| sSimplePolygonizer | Multipolygone à partir de lignes fermées ; la géométrie d'entrée si elles ne le sont pas.Multipolygon from closed lines; the input geometry when they are not closed. | |
| Geo/Geometric Operators | sProj | Reprojette les géométries d'un système EPSG vers un autre.Reprojects geometries from one EPSG system to another. |
| sClipperBox | Découpe les géométries par un rectangle (intersection).Clips geometries with a rectangle (intersection). | |
| sDissolver | Fusionne les surfaces adjacentes d'un même groupe.Merges adjacent areas of the same group. | |
| sCascadedPolygonUnion | Fusionne les surfaces d'un groupe en supprimant les limites communes.Merges the areas of a group by removing common boundaries. | |
| Geo/Collectors | sBoundingBoxAccumulator | Rectangle englobant de chaque groupe d'objets.Bounding box of each group of features. |
| sConvexHullAccumulator | Enveloppe convexe de chaque groupe d'objets.Convex hull of each group of features. | |
| sNeighborFinder | Objet le plus proche, cherché dans un flux Lookup dont la clé est la géométrie.Nearest feature, searched in a Lookup flow keyed on the geometry. | |
| Geo/Data Quality | sGeomValidator | La géométrie est-elle valide ?Is the geometry valid? |
| Geo/Geocoding | sFindPlaceName web | Nom du lieu le plus proche (géocodage inverse GeoNames).Nearest place name (GeoNames reverse geocoding). |
| sFindPostalCode web | Codes postaux les plus proches (géocodage inverse GeoNames).Nearest postal codes (GeoNames reverse geocoding). | |
| Geo/Metadata | sMetadataCreator | Fichier XML de métadonnées ISO 19139.ISO 19139 XML metadata file. |
| sMEFCreator | Fichier au format Metadata Exchange Format (MEF).Metadata Exchange Format (MEF) file. | |
| sCataloguePublisher | Publie les métadonnées d'une sortie Spatial dans un catalogue (GeoNetwork).Publishes the metadata of a Spatial output to a catalog (GeoNetwork). | |
| sESRIArcCatalog_to_ISO19115 · sISO19115_to_ISO19139FR · sISO19139_to_ISO19139FR · sISO19139FR_to_ISO19139 | Conversions XSLT de métadonnées : ArcCatalog d'ESRI, ISO 19115, ISO 19139 et son profil France.XSLT metadata conversions: ESRI ArcCatalog, ISO 19115, ISO 19139 and its French profile. | |
| sCSWRequest bac à sablesandbox | Envoie une requête POST à un serveur CSW.Sends a POST request to a CSW server. |
.shp ; les .dbf, .shx et .prj sont lus ou écrits à côté.File name: the .shp; the .dbf, .shx and .prj are read or written next to it..prj ou des géométries.Force CRS: imposes an EPSG code instead of the one from the .prj or the geometries."the_geom" par défaut).Host, port, database, schema, user, password, table, and geometry column ("the_geom" by default).fid et un index spatial GiST.On output, the table is dropped then recreated on every run, name and columns in lower case, with a fid key and a GiST spatial index."EPSG:4326" donnent geometry(Point,4326). GEOMETRY (par défaut) crée une colonne sans type précis.The column type and SRID come from the geometry type and the forced CRS: POINT and "EPSG:4326" give geometry(Point,4326). GEOMETRY (default) creates a column without a precise type."EPSG:4326" par défaut) et CRS cible.Source CRS ("EPSG:4326" by default) and target CRS.4326,2154=<WKT de la transformation>. Le modèle livré, .spatial/proj/epsg_operations.properties, et la grille ntf_r93.gsb sont copiés dans le workspace au premier job qui s'en sert.Custom transformation: properties file where 4326,2154=<transformation WKT>. The shipped template, .spatial/proj/epsg_operations.properties, and the ntf_r93.gsb grid are copied into the workspace by the first job that uses them.
Fonctions statiques, appelées par leur classe : GeometryOperation.GETAREA(row1.the_geom). Les géométries sont des Geometry ; celles renvoyées gardent le système de coordonnées de la première.
Static functions, called through their class: GeometryOperation.GETAREA(row1.the_geom). Geometries are Geometry objects; returned ones keep the coordinate system of the first.
| GETAREA(g) · GETLENGTH(g) | Surface, longueur (Double).Area, length (Double). |
| GETNUMPOINTS(g) · GETNUMGEOMETRIES(g) · GETGEOMETRYTYPE(g) · GETSRID(g) | Nombre de points, de géométries, type ("Point"…), SRID.Number of points, of geometries, type ("Point"…), SRID. |
| PROJ(g, "EPSG:4326", "EPSG:2154", lenient) | Reprojection d'une géométrie.Reprojects a geometry. |
| GETCENTROID(g) · GETINTERIORPOINT(g) · GETENVELOPE(g) · GETBOUNDARY(g) · GETCONVEXHULL(g) | Géométries dérivées.Derived geometries. |
| GETBUFFER(g, distance, segments, "ROUND") | Zone tampon ; extrémités "ROUND", "SQUARE", "BUTT" ou "FLAT".Buffer; end caps "ROUND", "SQUARE", "BUTT" or "FLAT". |
| INTERSECTION(g1, g2) · UNION · DIFFERENCE · SYMDIFFERENCE | Opérations ensemblistes.Set operations. |
| EQUALS(g1, g2) · DISTANCE(g1, g2) | Égalité, distance.Equality, distance. |
| GETGEOMETRYN(g, n) · GETCOORDINATE(g, n, "X") | n-ième géométrie ; coordonnée X, Y ou Z du n-ième point (-1 : le dernier).n-th geometry; X, Y or Z coordinate of the n-th point (-1: the last one). |
| SIMPLIFY(g, type, tolérance) · PRECISIONREDUCER(g, décimales) | Simplification ; arrondi des coordonnées.Simplification; coordinate rounding. |
| ISVALID(g) · TOWKT(g) | Validité ("true"/"false"), texte WKT.Validity ("true"/"false"), WKT text. |
INTERSECTS, TOUCHES, CROSSES, CONTAINS, WITHIN, COVERS, COVEREDBY, DISJOINT, OVERLAPS, tous (g1, g2).Predicates: INTERSECTS, TOUCHES, CROSSES, CONTAINS, WITHIN, COVERS, COVEREDBY, DISJOINT, OVERLAPS, all (g1, g2).RELATE(g1, g2) : matrice DE-9IM ; RELATE(g1, g2, "T*F**FFF*") : test d'une matrice.RELATE(g1, g2): DE-9IM matrix; RELATE(g1, g2, "T*F**FFF*"): matrix test.GETDISTANCE(g1, g2), ISWITHINDISTANCE(g1, g2, d), GETCLOSESTPOINT(g1, g2).GETDISTANCE(g1, g2), ISWITHINDISTANCE(g1, g2, d), GETCLOSESTPOINT(g1, g2).GeometryUtility.GMLToGeometry(gml, valider) : géométrie à partir d'un fragment GML 3 (<gml:Point>…).GeometryUtility.GMLToGeometry(gml, validate): geometry from a GML 3 fragment (<gml:Point>…).OpenStreetMap.GETTAGVALUE(tags, "name") : valeur d'une balise dans la colonne des balises lue par sOSMNodesInput ou sOSMWaysInput.OpenStreetMap.GETTAGVALUE(tags, "name"): value of a tag in the tags column read by sOSMNodesInput or sOSMWaysInput.Les composants Spatial reposent sur GeoTools 35.2 et JTS 1.20. Pour ce qu'ils ne font pas (une autre source, une jointure spatiale, un calcul particulier), un tJava, un tJavaRow ou une routine du projet peut appeler GeoTools directement. Les extraits de cette section ont été exécutés sous Java 21 avec les bibliothèques livrées ; les paramètres PostGIS sont ceux qu'emploie sPostgisInput. The Spatial components rely on GeoTools 35.2 and JTS 1.20. For what they do not do (another source, a spatial join, a specific calculation), a tJava, a tJavaRow or a project routine can call GeoTools directly. The snippets of this section were run on Java 21 with the shipped libraries; the PostGIS parameters are those sPostgisInput uses.
| DataStore | Une source : un shapefile, une base PostGIS, un service WFS. Toutes se lisent avec la même API ; DataStoreFinder.getDataStore(paramètres) trouve la bonne.A source: a shapefile, a PostGIS database, a WFS service. All are read with the same API; DataStoreFinder.getDataStore(parameters) finds the right one. |
| SimpleFeatureSource · SimpleFeatureStore | Une couche (fichier, table), en lecture ou en écriture.A layer (file, table), read-only or writable. |
| SimpleFeature | Un objet : ses attributs (getAttribute("nom")) et sa géométrie (getDefaultGeometry()).A feature: its attributes (getAttribute("nom")) and its geometry (getDefaultGeometry()). |
| org.locationtech.jts.geom.Geometry | La géométrie JTS : aire, longueur, buffer, intersection, prédicats.The JTS geometry: area, length, buffer, intersection, predicates. |
| CRS · MathTransform · JTS | Systèmes de coordonnées (CRS.decode("EPSG:2154")) et reprojection (JTS.transform).Coordinate reference systems (CRS.decode("EPSG:2154")) and reprojection (JTS.transform). |
| Filter (CQL) | Sélection des objets, en texte : ECQL.toFilter("pop > 1000000"). Sur PostGIS, le filtre devient du SQL exécuté par la base.Feature selection, as text: ECQL.toFilter("pop > 1000000"). On PostGIS, the filter becomes SQL run by the database. |
GeometryOperation.TOWKT(…)…) a les projections, la base EPSG et JTS, mais pas les formats de fichiers ni de bases.A lone tJava that uses a Spatial routine (GeometryOperation.TOWKT(…)…) has projections, the EPSG database and JTS, but not the file or database formats.
Les imports se mettent dans l'onglet Paramètres avancés › Import du tJava ; ils valent pour tout le job. N'importez pas org.locationtech.jts.geom.Geometry : les composants Spatial importent déjà org.talend.sdi.geometry.Geometry, le type des colonnes, et le nom Geometry deviendrait ambigu (le job ne compile plus). Écrivez la géométrie JTS avec son nom complet ; import org.locationtech.jts.geom.*; reste possible.
Imports go in the Advanced settings › Import tab of the tJava; they apply to the whole job. Do not import org.locationtech.jts.geom.Geometry: the Spatial components already import org.talend.sdi.geometry.Geometry, the column type, and the name Geometry would become ambiguous (the job no longer compiles). Write the JTS geometry with its full name; import org.locationtech.jts.geom.*; is still possible.
Imports :Imports:
import org.geotools.api.data.*;
import org.geotools.api.feature.simple.*;
import org.geotools.data.simple.SimpleFeatureIterator;
import org.geotools.filter.text.ecql.ECQL;
Code :Code:
java.io.File file = new java.io.File("C:/donnees/villes.shp");
DataStore in = DataStoreFinder.getDataStore(java.util.Map.of("url", file.toURI().toURL()));
try {
SimpleFeatureSource source = in.getFeatureSource(in.getTypeNames()[0]);
try (SimpleFeatureIterator it = source.getFeatures(ECQL.toFilter("pop > 1000000")).features()) {
while (it.hasNext()) {
SimpleFeature f = it.next();
org.locationtech.jts.geom.Geometry g = (org.locationtech.jts.geom.Geometry) f.getDefaultGeometry();
System.out.println(f.getAttribute("nom") + " " + g);
}
}
} finally {
in.dispose(); // libère le fichier
}
Paris POINT (2.35 48.85)
En plus des imports précédents :In addition to the previous imports:
import org.geotools.data.DefaultTransaction;
import org.geotools.data.collection.ListFeatureCollection;
import org.geotools.data.shapefile.ShapefileDataStoreFactory;
import org.geotools.feature.simple.*;
import org.geotools.referencing.CRS;
import org.locationtech.jts.geom.*;
SimpleFeatureTypeBuilder tb = new SimpleFeatureTypeBuilder();
tb.setName("villes");
tb.setCRS(CRS.decode("EPSG:4326", true));
tb.add("the_geom", Point.class); // buildFeature suit cet ordre
tb.add("nom", String.class);
tb.add("pop", Integer.class);
SimpleFeatureType type = tb.buildFeatureType();
GeometryFactory gf = new GeometryFactory();
SimpleFeatureBuilder fb = new SimpleFeatureBuilder(type);
java.util.List<SimpleFeature> villes = new java.util.ArrayList<>();
villes.add(fb.buildFeature(null, gf.createPoint(new Coordinate(2.35, 48.85)), "Paris", 2100000));
villes.add(fb.buildFeature(null, gf.createPoint(new Coordinate(4.84, 45.76)), "Lyon", 520000));
java.io.File file = new java.io.File("C:/donnees/villes.shp");
DataStore out = new ShapefileDataStoreFactory().createNewDataStore(java.util.Map.of("url", file.toURI().toURL()));
try {
out.createSchema(type);
// La couche porte le nom du fichier, pas celui du schéma.
String typeName = out.getTypeNames()[0];
SimpleFeatureStore store = (SimpleFeatureStore) out.getFeatureSource(typeName);
try (Transaction tx = new DefaultTransaction("ecriture")) {
store.setTransaction(tx);
store.addFeatures(new ListFeatureCollection(type, villes));
tx.commit();
}
} finally {
out.dispose();
}
import org.geotools.geometry.jts.JTS;
import org.geotools.referencing.CRS;
import org.locationtech.jts.io.WKTReader;
org.geotools.api.referencing.crs.CoordinateReferenceSystem wgs84 = CRS.decode("EPSG:4326", true);
org.geotools.api.referencing.crs.CoordinateReferenceSystem l93 = CRS.decode("EPSG:2154", true);
org.geotools.api.referencing.operation.MathTransform versL93 = CRS.findMathTransform(wgs84, l93, true);
org.locationtech.jts.geom.Geometry paris = new WKTReader().read("POINT (2.35 48.85)");
System.out.println(JTS.transform(paris, versL93));
org.locationtech.jts.geom.Geometry carre = new WKTReader().read(
"POLYGON ((2.35 48.85, 2.36 48.85, 2.36 48.86, 2.35 48.86, 2.35 48.85))");
System.out.println(carre.getArea()); // en degrés carrés
System.out.println(Math.round(JTS.transform(carre, versL93).getArea())); // en m²
POINT (652301.5648687112 6861302.730537979)
9.999999999997797E-5
815903
Même API et mêmes imports qu'un shapefile ; seuls les paramètres changent :Same API and imports as a shapefile; only the parameters change:
java.util.Map<String, Object> params = new java.util.HashMap<>();
params.put("dbtype", "postgis");
params.put("host", "localhost");
params.put("port", 5432);
params.put("database", "geo");
params.put("schema", "public");
params.put("user", context.pg_user);
params.put("passwd", context.pg_password);
DataStore db = DataStoreFinder.getDataStore(params);
SimpleFeatureSource villes = db.getFeatureSource("villes");
Dans un tJavaRow, entre le type des colonnes et JTS :In a tJavaRow, between the column type and JTS:
org.locationtech.jts.geom.Geometry g = input_row.the_geom._getInternalGeometry();
output_row.the_geom = new org.talend.sdi.geometry.Geometry(g.buffer(100));
output_row.the_geom.setCRS("EPSG:2154");
CRS.decode("EPSG:4326") suit la définition officielle : latitude d'abord. CRS.decode("EPSG:4326", true) met la longitude d'abord, l'ordre des WKT, des shapefiles, de PostGIS et des colonnes Geometry. Gardez true partout.Axis order. CRS.decode("EPSG:4326") follows the official definition: latitude first. CRS.decode("EPSG:4326", true) puts longitude first, the order of WKT, shapefiles, PostGIS and Geometry columns. Keep true everywhere.getTypeNames()[0] après createSchema.Layer name. A shapefile has a single layer, named after the file: read it back with getTypeNames()[0] after createSchema.dispose() sur le DataStore, et fermeture des itérateurs (try (…)), libèrent fichiers et connexions.Closing. dispose() on the DataStore, and closing the iterators (try (…)), release files and connections.org.opengis.* et com.vividsolutions.jts.* : ici, org.geotools.api.* et org.locationtech.jts.*.Old examples. Code written for a GeoTools older than version 30 uses org.opengis.* and com.vividsolutions.jts.*: here, org.geotools.api.* and org.locationtech.jts.*.Pour aller plus loin : le guide de GeoTools (tutoriels Quickstart, Feature, CRS) et la javadoc de JTS. To go further: the GeoTools guide (Quickstart, Feature, CRS tutorials) and the JTS javadoc.
Quatre jobs exécutés tels quels avec Talaxie sous Java 21. Chacun commence par un tFixedFlowInput d'une ligne : une colonne nom (String) et une colonne the_geom (Geometry).
Four jobs run as is with Talaxie on Java 21. Each starts with a one-row tFixedFlowInput: a nom column (String) and a the_geom column (Geometry).
Valeur de the_geom :the_geom value:
org.talend.sdi.geometry.Geometry.parseGeometry("POLYGON ((0 0, 2 0, 2 2, 0 2, 0 0))")
sAreaCalculator ajoute la colonne area (Double) ; le tLogRow affiche nom et area :sAreaCalculator adds the area column (Double); the tLogRow prints nom and area:
Carré|4.0
Paris en WGS 84, CRS source "EPSG:4326", CRS cible "EPSG:2154" :Paris in WGS 84, source CRS "EPSG:4326", target CRS "EPSG:2154":
org.talend.sdi.geometry.Geometry.parseGeometry("POINT (2.35 48.85)")
Le point sort en mètres, vers x = 652 000 et y = 6 862 000. Sans composant, dans une expression :The point comes out in metres, near x = 652,000 and y = 6,862,000. Without a component, in an expression:
GeometryOperation.PROJ(row1.the_geom, "EPSG:4326", "EPSG:2154", false)
"C:/donnees/villes.shp".Both components: file name "C:/data/villes.shp".Paris|POINT (2.35 48.85)
"public", utilisateur, mot de passe, table "villes", colonne "the_geom".Both components: host, port, database, "public" schema, user, password, "villes" table, "the_geom" column."EPSG:4326".sPostgisOutput: POINT type, forced CRS "EPSG:4326".Paris|POINT (2.35 48.85)
Côté base :On the database side:
SELECT nom, ST_AsText(the_geom), ST_SRID(the_geom) FROM villes;
nom | st_astext | st_srid
-------+-------------------+---------
Paris | POINT(2.35 48.85) | 4326
id_Geometry.Jobs reopen as they are: same component names, same parameters, same id_Geometry type.com.vividsolutions.jts.geom.Point…, versions WFS org.geotools.data.wfs.protocol.wfs.Version.v1_0_0…Old saved values are converted at generation: geometry types com.vividsolutions.jts.geom.Point…, WFS versions org.geotools.data.wfs.protocol.wfs.Version.v1_0_0…com.vividsolutions.jts → org.locationtech.jts, org.opengis → org.geotools.api, org.geotools.data.DataStore → org.geotools.api.data.DataStore (voir GeoTools en Java).Java code in a tJava or tJavaRow that names JTS or GeoTools must follow their new packages: com.vividsolutions.jts → org.locationtech.jts, org.opengis → org.geotools.api, org.geotools.data.DataStore → org.geotools.api.data.DataStore (see GeoTools in Java).java.util.logging ; le niveau choisi dans le composant s'applique toujours.GeoTools logs go through java.util.logging; the level chosen in the component still applies.sOgrInput, sOgrOutput, sGdalInfoInput, sOGRInfoInput) : présents dans la palette mais inutilisables, car ils dépendent encore de GeoTools 8.5 et des bibliothèques natives de GDAL.GDAL/OGR (sOgrInput, sOgrOutput, sGdalInfoInput, sOGRInfoInput): in the palette but unusable, as they still depend on GeoTools 8.5 and on the GDAL native libraries.sCSWRequest, sGeoServerPublisher, sNetCDFInput, sOPeNDAPInput, sThreddsIterator) : livrés tels quels, sans GeoTools ; leurs bibliothèques anciennes sont prises sur Maven Central.Sandbox (sCSWRequest, sGeoServerPublisher, sNetCDFInput, sOPeNDAPInput, sThreddsIterator): shipped as they were, without GeoTools; their old libraries come from Maven Central.