DXF
Endpoint
POST https://api.geoflip.io/v1/transform/dxf
Payload Example (Multipart Form)
To submit a DXF file, the file must be provided in a multi-part form submission and for you must provide an input_crs
in your config.
<html>
<input type="file" id="fileInput" accept=".dxf" />
<button id="uploadButton">Upload and Convert DXF</button>
<a id="downloadLink" style="display:none;">Download Converted File</a>
<script>
document.getElementById('uploadButton').addEventListener('click', () => {
const selectedFile = document.getElementById('fileInput').files[0];
const formData = new FormData();
formData.append('file', selectedFile); // DXF file
const config = {
output_format: "geojson",
input_crs: "EPSG:4326", // Required for DXF
transformations: [
{
type: "buffer",
distance: 100,
units: "meters"
}
]
};
formData.append('config', JSON.stringify(config));
axios.post('https://api.geoflip.io/v1/transform/dxf', formData, {
headers: {
'Content-Type': 'multipart/form-data',
"apiKey": "YOUR_API_KEY"
}
})
.then(response => {
console.log("File converted successfully:", response.data);
})
.catch(error => {
console.error("Error converting file:", error);
});
});
</script>
<script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
</html>
Explanation
-
API Key: Your Geoflip API key must be provided in the request headers. You can create an API key here.
-
Input CRS: The input_crs must be provided in the config for DXF files since they do not contain CRS information inherently. This ensures that the spatial data can be correctly transformed and interpreted.
-
Multipart Submission: DXF files must be provided in the
file
part of the multipart form. -
Config Component: The config component is where you define output details (
output_format
,output_crs
) and specify transformations. -
Transformations: Transformations can be specified in the request payload using the transformations parameter. These transformations allow operations like buffering and more complex spatial manipulation. Read more about available geoflip transformations here.
-
Output Format: The
output_format
can be one ofdxf
,shp
,geojson
, orgeopackage
. -
Output CRS: The
output_crs
can be any valid EPSG code, such asEPSG:4326
.
Note that requesting a binary file output (e.g., dxf, shp, geopackage) will return a blob in the response, while requesting a geojson output will return the required GeoJSON in the response body.
Key Considerations
-
DXF is a CAD file format used for vector data such as lines, points, and polygons.
-
Users must specify the CRS (
input_crs
) since DXF files lack this information, which is critical for accurate spatial transformations. -
Multipart form submission ensures that the binary DXF file and its configurations are transmitted correctly.