Socket
Book a DemoInstallSign in
Socket

dxf-polygon-importer

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dxf-polygon-importer

Imports and converts polylines to polygons from a DXF file to a PostGIS table.

latest
npmnpm
Version
0.2.3
Version published
Maintainers
1
Created
Source

Codeship Status for sasaki_dev/dxf-polygon-importer

DXF Polygon Importer

Parses a DXF file and imports closed 'CAD Polylines' as polygons and labels as points into a PostGIS table. The imports will be versioned based on a project identifier and filename combination.

Installation and requirements

npm install dxf-polygon-importer

The module requires ogr2ogr and a PostGIS enabled PostgreSQL database connection.

Following environment variables need to be set:

DXF_TOOLS_DB_HOST      ...  PostgreSQL server host
DXF_TOOLS_DB_USER      ...  Database user name
DXF_TOOLS_DB_PASSWORD  ...  Database user password
DXF_TOOLS_DB_NAME      ...  Database name

The module creates following database tables and views:

dxf_features [table]   ...  all imported geometries
all_polygons [view]    ...  last version of imported polygons
all_labels   [view]    ...  last version of imported label points

Usage

var Importer = require('dxf-polygon-importer');

Importer('mydrawing.dxf', {
  polygonLayer: 'MYPOLYLINES',
  labelLayer: 'MYNAMES',
  project: 'MyProject'
}).go().then(function (data) {
  // handle data
  // { filename: 'mydrawing.dxf', project: 'MyProject', version: 1 }
});

API

initialize Importer(file, options)

The class takes a DXF file path as first file argument and options object with following properties as second:

{
  polygonLayer: String,  ...  CAD layer containing polygons
  labelLayer: String,    ...  CAD layer containing labels
  project: String        ...  Unique project identifier
}

go Importer.go(keepPool)

Initiates the import process with schema-setup, polyline-conversions and sql-inserts. The method takes a keepPool Boolean argument to indicate if database connection pool should be kept alive or torn down after import. This can be useful if the pool should be used for multiple subsequent imports. Default value is falsy, 'undefined'.

destroy Importer.destroy()

Alias to terminate database connection pool.

Keywords

cad

FAQs

Package last updated on 15 Dec 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts