我是基于 gis 的项目的新手。我正在使用 netbeans IDE 来包含我的 shapefile,并且我确信我已经导入了必要的 jar 来包含 shapefile。但它不起作用。当我运行我的应用程序时,我在 simplefeaturesource 方法中得到一个空指针异常。在此我包括我的程序
public class Quickstart {
/**
* GeoTools Quickstart demo application. Prompts the user for a shapefile and displays its
* contents on the screen in a map frame
*/
public static void main(String[] args) throws Exception {
// display a data store file chooser dialog for shapefiles
File file = JFileDataStoreChooser.showOpenFile("shp", null);
if (file == null) {
return;
}
FileDataStore store = FileDataStoreFinder.getDataStore(file);
SimpleFeatureSource featureSource = store.getFeatureSource();
// Create a map content and add our shapefile to it
MapContent map = new MapContent();
map.setTitle("Quickstart");
Style style = SLD.createSimpleStyle(featureSource.getSchema());
Layer layer = new FeatureLayer(featureSource, style);
map.addLayer(layer);
// Now display the map
JMapFrame.showMap(map);
}
}