DataSourcesFile


Supported with:
  • Engine
  • ArcView
  • ArcEditor
  • ArcInfo
  • Server
Library dependencies: System, SystemUI, Geometry, Display, Server, Output, Geodatabase, GISClient

Additional library information: Contents, Object Model Diagram

The DataSourcesFile library contains the implementation of the geodatabase application programming interface (API) for file based data sources. These file based data sources include: shapefile, coverage, triangulated irregular network (TIN), computer-aided design (CAD), Smart Data Compression (SDC), StreetMap, and Vector Product Format (VPF).
 
 

See the following sections for more information about this namespace:

Coverage

Workspace factory classes are the entry point for accessing data with geodatabase objects for any data format. The type of workspace factory you instantiate dictates the type of data that can be handled by the workspace factory object and its derivatives.
To work with ArcInfo coverage or table data, create a workspace factory using the ArcInfoWorkspaceFactory class. After creating a new instance of the ArcInfoWorkspaceFactory object, use the open or openFromFile method to get a workspace object that is used to work with the data. See the following illustration:
The following are values specific to ArcInfoWorkspaceFactory:
  • IWorkspaceFactory.copy and IWorkspaceFactory.move cannot be used.
  • IWorkspaceFactory.getWorkspaceDescription returns ARC/INFO workspace.
  • IWorkspaceFactory.getWorkspaceType returns 0 or esriFileSystemWorkspace.
  • IWorkspaceFactory.isWorkspace returns true or false depending on whether or not there is an INFO subdirectory present.
  • IWorkspaceFactory.readconnectionPropertiesFromFile returns a PropertySet object, with the only property being DATABASE, which is set to the path name.
The workspace object is created by the ArcInfoWorkspaceFactory when the open or openFromFile methods are used. The class has interfaces with methods that include creating new ArcInfo coverages or INFO table data, renaming workspaces, and deleting ArcInfo coverages. Instances of this class can be created explicitly, but it should only be created by the workspace factory class.
IArcInfoWorkspace.createCoverage creates a new ArcInfo coverage in the workspace that is being referenced. The IFeatureDataset that is returned can be used to create new feature classes in the coverage. If a template coverage is not specified or the name is not a valid coverage, the new coverage will have an empty .tic file. When a template coverage is used, the new coverage will have the same .tic files: .bnd (boundary) and .prj (projection). The precision enumerator esriCoveragePrecisionType is used to specify whether the coverage has single precision (seven significant digits for each coordinate) or double precision (15 significant digits for each coordinate). CreateCoverage will throw an exception if CoverageName is a path (such as D:/data/canada), if it is longer than 13 characters, or if it exists.
IArcInfoWorkspace.createInfoTable creates a new INFO table in the workspace that is being referenced. The ITable pointer that is returned can be used to add and delete items in the table. The name argument for the name of the new table can be up to 32 characters long, inclusive of the extension. The name cannot be an existing INFO table. The table will be created in the workspace used by the IArcInfoWorkspace; path names are recognized by this method. The ArcInfoItems object must be given, although it does not have to contain any items. If the  ArcInfoItems contains items, they will be created in the new table.
The ICoverage interface provides information about coverages and processing operations specific to ArcInfo coverages. This interface can be used to create or update the topology of a coverage and set various tolerances that are used in coverage editing and processing. Tolerance values are considered to be verified if the specified tolerance value has been used to process the coverage, with the exception of the ArcEdit tolerances. Edit, nodesnap, weed, grain, and snap are verified as soon as they have been explicitly set. See the following illustration:
The Table object is a collection of ArcInfo items (columns) and rows. All types of data use tables to store information about its features, but with ArcInfo the data is stored in an INFO table.
The IArcInfoTable interface is used to access and modify the items in the INFO table. With this interface, you can add or delete items, add or delete an index for an item, and change the properties of an item. This interface is used to get the items collection, with which you can get or set information for individual items. See the following illustration:
A FeatureClass object is a collection of features that have the same feature type and set of attributes. The ICoverageFeatureClass interface provides information on an individual feature class of an ArcInfo coverage. See the following illustration:
The ArcInfoItems object represents the item set, or collection of items, in an INFO table. This object is similar to the Fields object used with tables from other data types. The ArcInfoItems object is an ordered collection of items, and the collection behaves like a list, so it is possible to access individual fields by a numbered position (or index) in the list. This class implements two interfaces. The IArcInfoItems interface is used to get the number of items, the index of an item, or an item object. The IArcInfoItemsEdit interface is used when creating or modifing an ArcInfoItems collection. For example, you can create a new ArcInfoItem object and add items to it, or you can get an item collection from an ArcInfo feature class and add or remove items from it.
An ArcInfoItem has many properties, the most obvious ones being its name and its data type. Use the IArcInfoItems interface to get the properties of an ArcInfo item. Use IArcInfoItemEdit to set the properties of an ArcInfo item. The esriItemType enumeration lists the possible data types for an ArcInfo item. See the following illustration:
A CoverageName object identifies and locates a dataset object and supports methods to instantiate the named object. A name object can be used as a lightweight surrogate of the object until further properties of the object are needed or additional methods on the object need to be called.
The CoverageName object can be used to retrieve information on the type of coverage, what is contained in the coverage, and the metadata for the coverage. It can be used to find the coverage type, which is based on the highest level of dimension, for the feature classes contained. Levels of dimensions refer to how many dimensions are used to measure the features; that is, a point has an x,y value, a line has length in addition to these values, and polygons have area. See the following illustration: 
A CoverageFeatureClassName object identifies and locates a feature class in a coverage; it is used for obtaining basic properties of the feature class without having to open (instantiate) it.
The ICoverageFeatureClassName interface has the same properties as the ICoverageFeatureClass interface, which is the get/setFeatureClassType if there is an attribute table, and the topology status. See the following illustration:
The following code example shows the process of converting a coverage to a feature class in a personal geodatabase. The polygon features in a coverage (states) are added to a feature class in a new personal geodatabase (states_con). The coverage dataset and the personal geodatabase (PGDB) dataset are passed to the FeatureDataConverter.convertFeatureDataset method.
[Java]
PropertySet props = new PropertySet();
props.setProperty("Database", "C:\\ArcGIS\\data\\usa");
AccessWorkspaceFactory awf = new AccessWorkspaceFactory();
WorkspaceName outWSName = new WorkspaceName(awf.create(
    "C:\\Program Files\\ArcGIS\\java\\samples\\data\\usa", "usa_con", props, 0));
FeatureDatasetName dsn = new FeatureDatasetName();
dsn.setWorkspaceNameByRef(outWSName);
dsn.setName("states_con");
WorkspaceName inWSName = new WorkspaceName();
inWSName.setPathName("C:\\arcgis\\ArcTutor\\Catalog\\Yellowstone");
inWSName.setWorkspaceFactoryProgID("esriDataSourcesFile.ArcInfoWorkspaceFactory.1");

FeatureDatasetName dsn2 = new FeatureDatasetName();
dsn2.setName("states");
dsn2.setWorkspaceNameByRef(inWSName);
FeatureDataConverter converter = new FeatureDataConverter();
converter.convertFeatureDataset(dsn2, dsn, null, "", 1000, 0);
The following code example shows how to use ArcObjects coverage features to convert into a shapefile:
[Java]
ArcInfoWorkspaceFactory workspaceFactory = new ArcInfoWorkspaceFactory();
Workspace workspace = new Workspace(workspaceFactory.openFromFile(
    "C:\\arcgis\\ArcTutor\\Catalog\\Yellowstone", 0));
// Identify the coverage and feature class to be converted.
IFeatureClass featClass = workspace.openFeatureClass("states:polygon");
IDataset dataset = new IDatasetProxy(featClass);
IName name = dataset.getFullName();
IFeatureClassName covFeatClassName = (IFeatureClassName)name;
// Open the workspace that will contain the new shapefile of
// converted coverage features.
WorkspaceName shapeWorkName = new WorkspaceName();
shapeWorkName.setWorkspaceFactoryProgID(
    "esriDataSourcesFile.ShapefileWorkspaceFactory");
shapeWorkName.setPathName("C:\\arcgis\\ArcTutor\\Catalog\\Yellowstone");
// Specify the name of the shapefile.
FeatureClassName shapeFeatClassName = new FeatureClassName();
IDatasetName dataSetName = (IDatasetName)shapeFeatClassName;
dataSetName.setName("states_converted");
dataSetName.setWorkspaceNameByRef(shapeWorkName);
// Convert the coverage features into shapefile features.
FeatureDataConverter featDataConv = new FeatureDataConverter();
featDataConv.convertFeatureClass(covFeatClassName, null, null, shapeFeatClassName,
    null, null, null, 1000, 0);

CAD

The ICadDrawingWorkspace interface on the Workspace object is used to open a CAD dataset. From the ICadDrawingDataset that is returned, retrieve CAD specific information about the dataset, such as its path, if it's from AutoCad, or if it's a .dgn file.

StreetMap

The StreetMap objects allow you to build routes between locations. There are objects to define the final and intermediate stops of the route, objects for adjusting parameters of search, routing task solver objects, as well as objects that provide details on the result path geometry and driving directions.
The first step is to create the factory of solver objects using the SMRouterFactory. Call ISMRouterFactory.createRouter() passing in the path to your routing data to create an SMRouter object and return an ISMRouter.
To find a route, create an SMPointsCollection object and add your stops into this collection. This object is passed to ISMRouter.solve which builds the route and returns an ISMDirections that contains resulting path geometry and driving directions texts.
It is possible to control how the route is built using the following ISMRoute interface members:
  • getPreferences allows access to the highways local roads preference for the router.
  • getNetAttributeName controls whether quickest or shortest route will be built by the router.
  • getBarriers is used to disable some points of the routing network.
  • getTripPlanSettings configures time frames for driving and resting periods of the trip.
  • Call reorderStops() to automatically optimize the order of several stops (traveling salesperson problem). 
The following code example shows how to use the StreetMap object library to create a simple route between two points from a StreetMap data source:
[Java]
SMRouterFactory factory = new SMRouterFactory();
// Get the StreetMap router from the StreetMap routing service data source
ISMRouter router = factory.createRouter(
    "C:\\arcgis\\ArcTutor\\StreetMap\\streets.rs");
router.getPreferences().setItem(esriSMRoadType.esriSMRoadTypeHighways,
    Short.parseShort("75"));
router.setNetAttributeName("Time");
// Create a collection of stops
ISMStopsCollection collection = new SMStopsCollection();
// Define the departure stop point.
ISMRouterPoint pt1 = new SMRouterPoint();
pt1.setX( - 87.124);
pt1.setY(33.447);
// Create a flag from the first point.
ISMFlag flag1 = router.getFlagCreator().createFlag(pt1);
// Create the stop and add the stop info.
ISMStop stop1 = new SMStop();
stop1.setFlag(flag1);
stop1.setDescription("Departure Point");
stop1.setDuration(Short.parseShort("0"));
stop1.setStopID(1000);
// Define the arrival stop point.
ISMRouterPoint pt2 = new SMRouterPoint();
pt2.setX( - 86.953);
pt2.setY(33.428);
// Create a flag for the second point.
ISMFlag flag2 = router.getFlagCreator().createFlag(pt2);
// Create the arrival stop and add the stop info.
ISMStop stop2 = new SMStop();
stop2.setFlag(flag2);
stop2.setDescription("Arrival Point");
stop2.setDuration(Short.parseShort("0"));
stop2.setStopID(1001);
// Add the stops to the collection.
collection.add(stop1);
collection.add(stop2);
// Solve the route.
ISMDirections directions = router.solve(collection, null);
System.out.println(directions.getTotalsText());
The following code example is almost identical to the preceding one, except that barriers are added to the route before it is solved:
[Java]
// Create the workspace factory for the StreetMap data source.
SMRouterFactory factory = new SMRouterFactory();
// Get the StreetMap router from the StreetMap routing service data source.
ISMRouter router = factory.createRouter(
    "C:\\arcgis\\ArcTutor\\StreetMap\\streets.rs");
router.getPreferences().setItem(esriSMRoadType.esriSMRoadTypeHighways,
    Short.parseShort("75"));
router.setNetAttributeName("Time");
// Create a collection of stops.
ISMStopsCollection collection = new SMStopsCollection();
// Define the departure stop point.
ISMRouterPoint pt1 = new SMRouterPoint();
pt1.setX( - 87.124);
pt1.setY(33.447);
// Create a flag from the first point.
ISMFlag flag1 = router.getFlagCreator().createFlag(pt1);
// Create the stop and add the stop info.
ISMStop stop1 = new SMStop();
stop1.setFlag(flag1);
stop1.setDescription("Departure Point");
stop1.setDuration(Short.parseShort("0"));
stop1.setStopID(1000);
// Define the arrival stop point.
ISMRouterPoint pt2 = new SMRouterPoint();
pt2.setX( - 86.953);
pt2.setY(33.428);
// Create a flag for the second point.
ISMFlag flag2 = router.getFlagCreator().createFlag(pt2);
// Create the arrival stop and add the stop info.
ISMStop stop2 = new SMStop();
stop2.setFlag(flag2);
stop2.setDescription("Arrival Point");
stop2.setDuration(Short.parseShort("0"));
stop2.setStopID(1001);
// Add the stops to the collection.
collection.add(stop1);
collection.add(stop2);
// Add a barrier.
ISMNetBarriersCollection bcol = router.getBarriers();
ISMRouterPoint bPoint = new SMRouterPoint();
ISMNetBarrier barrier = new SMNetBarrier();
bPoint.setX( - 87.103);
bPoint.setY(33.457);
barrier.setBarrierID(1200);
barrier.setPoint(bPoint);
bcol.add(barrier);
// Solve the route.
ISMDirections directions = router.solve(collection, null);
System.out.println(directions.getTotalsText());