我们正在构建一个上传包含ESRI-shapefile的zip文件的服务.该服务应该能够读取shapefile并对其内容进行处理.所以我构建了一个将zip文件解压缩到临时文件夹(System.getProperty("java.io.tmpdir")的子文件夹)的类.
另一个类从Unzip-class调用unzip方法,然后尝试使用Geotools读取解压缩的shapefile.它使用Geotools DataStoreFinder.getDataStore(Map params)方法从解压缩的shapefile创建数据存储区.这里出现问题:getDataStore-method返回null.我测试了URL,它看起来很好.URL所源自的文件是一个文件,可以由应用程序读取(使用shapefile.exists(),shapefile.isFile(),shapefile.canRead()进行测试).那么,可能出现什么问题呢?为什么我返回null?
这是(相关)代码:
import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import org.geotools.data.DataStore;
import org.geotools.data.DataStoreFinder;
import org.geotools.data.FeatureSource;
import org.geotools.feature.FeatureCollection;
import org.geotools.feature.FeatureIterator;
import org.opengis.feature.simple.SimpleFeature;
import org.opengis.feature.simple.SimpleFeatureType;
import com.geodan.equus.entity.dataset.BasicFeature;
import com.geodan.equus.exception.EquusException;
import com.geodan.equus.processor.EquusProcessor;
import com.geodan.util.io.UnzipUtils;
import com.vividsolutions.jts.geom.Geometry;
public class ShapefileProcessor implements EquusProcessor
{
private static final File TEMP_UNZIP_DIR = new File(
System.getProperty("java.io.tmpdir") + File.separator
+ "atlas_temp_unzip_dir");
public static Set<BasicFeature> importFeatures(final File zipFile)
throws EquusException
{
// Check if the input file has the zipfile …Run Code Online (Sandbox Code Playgroud) 我正在尝试运行使用AngularJS和RequireJS的应用程序.我在让OpenLayers lib在此设置中工作时遇到问题.
我在main.js中设置了主要的AMD模块:
require.config(
{
baseUrl: 'scripts',
paths: {
// Vendor modules
angular: 'vendor/angular/angular',
openLayers: 'vendor/openlayers-debug',
other modules.....
},
shim: {
angular: {
exports: 'angular'
},
openLayers: {
exports: 'OpenLayers'
},
other modules....
}
}
);
require(['openLayers',
'angular',
'app',
'controllers/olMapController',
'directives/olMap',
other modules...
], function(OpenLayers) {
return OpenLayers;
}
);
Run Code Online (Sandbox Code Playgroud)
然后在我用于初始化OpenLayers的角度控制器中,我试着指出openlayers-debug.js是一个依赖:
define(['openLayers'],
function(OpenLayers) {
controllers.controller('olMapController', ['$scope', function(scope) {
console.log('Loaded olMapController. OpenLayers version: ' + OpenLayers.VERSION_NUMBER);
}]);
}
);
Run Code Online (Sandbox Code Playgroud)
嗯,这不起作用.有时执行olMapController函数,但大部分都没有.然后控制台只显示一个错误说明:
错误:[ng:areq]参数'olMapController'不是函数,未定义
所以,我认为OpenLayers尚未完成加载,但不知何故需要认为它已经并继续加载依赖于OpenLayers的代码,在本例中是olMapController.然后它无法找到它的依赖关系,于是Angular返回此错误消息.或类似的东西...?有时发生的事情会使OpenLayers加载得很快,因为当它作为依赖项加载时它会出现.那是什么,我说不出来.
我遗漏了其他库和模块需要并定义以保持代码可读.我希望这个例子仍然可以理解.
有什么想法可以让openlayers加载好吗?当我将['openLayers']依赖项从olMapController中删除时,错误消息消失.
在此先感谢您的帮助.
最好的问候,Martijn Senden
angularjs ×1
geotools ×1
java ×1
javascript ×1
null ×1
openlayers ×1
require ×1
requirejs ×1
unzip ×1