geoserver 上传压缩包文件

package com.geoTools;

import it.geosolutions.geoserver.rest.GeoServerRESTPublisher;
import it.geosolutions.geoserver.rest.GeoServerRESTReader;
import it.geosolutions.geoserver.rest.decoder.RESTDataStore;
import it.geosolutions.geoserver.rest.decoder.RESTLayerGroupList;
import it.geosolutions.geoserver.rest.encoder.datastore.GSDirectoryOfShapefilesDatastoreEncoder;
import it.geosolutions.geoserver.rest.manager.GeoServerRESTStoreManager;

import java.io.File;
import java.net.MalformedURLException;
import java.nio.charset.Charset;
import java.util.List;

public class t {
public static final String RESTURL = “http://localhost:8090/geoserver/“;
public static final String RESTUSR = “admin”;
public static final String RESTPWD = “geoserver”;

public static void main(String[] args) throws Exception {

    GeoServerRESTReader reader = new GeoServerRESTReader(RESTURL, RESTUSR, RESTPWD);
    GeoServerRESTPublisher publisher = new GeoServerRESTPublisher(RESTURL, RESTUSR, RESTPWD);

// createWorkspace(“wangtao”);

// publisher.removeWorkspace(“tt”, true);// 递归删除 layer datastore
geoserverShape();

}

public static void geoserverShape() throws Exception {
    File zipFile = new File("C:\\Users\\Administrator\\Desktop\\tooltest\\tooltest.zip");
    GeoServerRESTReader reader = new GeoServerRESTReader(RESTURL, RESTUSR, RESTPWD);
    GeoServerRESTPublisher publisher = new GeoServerRESTPublisher(RESTURL, RESTUSR, RESTPWD);


    boolean published = publisher.publishShp("wangtao", "test", "jialigongyu", zipFile, "EPSG:404000", "point");
}

public static void createLayerGroups () throws MalformedURLException {
    GeoServerRESTReader reader = new GeoServerRESTReader(RESTURL, RESTUSR, RESTPWD);
    GeoServerRESTPublisher publisher = new GeoServerRESTPublisher(RESTURL, RESTUSR, RESTPWD);

    RESTLayerGroupList allGroups = reader.getLayerGroups();
}


/**
 * 创建工作空间
 *
 * @param workspaceName 工作空间名称
 * @return
 * @throws MalformedURLException
 */
public static boolean createWorkspace(String workspaceName) throws MalformedURLException {
    GeoServerRESTReader reader = new GeoServerRESTReader(RESTURL, RESTUSR, RESTPWD);
    GeoServerRESTPublisher publisher = new GeoServerRESTPublisher(RESTURL, RESTUSR, RESTPWD);

    List<String> workspaceNames = reader.getWorkspaceNames(); // 获取所有工作空间
    if (workspaceNames.contains(workspaceName)) {
        System.out.println("存在该工作空间");
        return false;
    } else {
        boolean created = publisher.createWorkspace(workspaceName);
        System.out.println("创建成功");
        return created;
    }
}

}

阅读更多
版权声明: https://blog.csdn.net/staHuri/article/details/80688541
文章标签: FME
个人分类: JAVA
想对作者说点什么? 我来说一句

geoserver-2.2.4-war.zip

2017年08月21日 51.33MB 下载

php实现上传文件并解压

tjyinuo2011 tjyinuo2011

2012-12-26 18:24:20

阅读数:967

java上传并自动解决ZIP文件

2007年10月20日 88KB 下载

没有更多推荐了,返回首页

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭