当前位置: 首页>>代码示例>>Java>>正文


Java Parser.parse方法代码示例

本文整理汇总了Java中org.geotools.xml.Parser.parse方法的典型用法代码示例。如果您正苦于以下问题:Java Parser.parse方法的具体用法?Java Parser.parse怎么用?Java Parser.parse使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.geotools.xml.Parser的用法示例。


在下文中一共展示了Parser.parse方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: handle

import org.geotools.xml.Parser; //导入方法依赖的package包/类
public void handle(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
	String requestName = request.getParameter("REQUEST");
	if ("GetCapabilities".equalsIgnoreCase(requestName)) {
		response.setContentType("application/xml");
		response.setStatus(HttpServletResponse.SC_OK);
		filterPortAndCopyToResponse(getClass().getResourceAsStream("capabilities_1_0_0.xml"), response);
	} else if ("DescribeFeatureType".equalsIgnoreCase(requestName)) {
		response.setContentType("text/xml");
		response.setStatus(HttpServletResponse.SC_OK);
		filterPortAndCopyToResponse(getClass().getResourceAsStream("describeFeatureType.xml"), response);
	} else if ("GetFeature".equalsIgnoreCase(requestName)) {
		response.setContentType("text/xml; subtype=gml/2.1.2; charset=UTF-8");
		response.setStatus(HttpServletResponse.SC_OK);
		// create the parser with the filter 1.0 configuration
		Configuration configuration = new org.geotools.filter.v1_0.OGCConfiguration();
		Parser parser = new Parser(configuration);
		try {
			Map map = (Map) parser.parse(request.getInputStream());
			lastFilter = (Filter) ((Map) map.get("Query")).get("Filter");
		} catch (Exception e) {
			e.printStackTrace();
		}
		filterPortAndCopyToResponse(getClass().getResourceAsStream("getFeature.xml"), response);
	}
}
 
开发者ID:geomajas,项目名称:geomajas-project-client-gwt2,代码行数:26,代码来源:WfsServlet.java

示例2: checkGMLFootprint

import org.geotools.xml.Parser; //导入方法依赖的package包/类
/**
 * Check GML Footprint validity
 */
private boolean checkGMLFootprint (String footprint)
{
   try
   {
      Configuration configuration = new GMLConfiguration ();
      Parser parser = new Parser (configuration);
      parser.parse (new InputSource (new StringReader (footprint)));
      return true;
   }
   catch (Exception e)
   {
      LOGGER.error("Error in extracted footprint: " + e.getMessage());
      return false;
   }
}
 
开发者ID:SentinelDataHub,项目名称:dhus-core,代码行数:19,代码来源:ProcessingManager.java

示例3: checkGMLFootprint

import org.geotools.xml.Parser; //导入方法依赖的package包/类
/**
 * Check GML Footprint validity
 */
public static boolean checkGMLFootprint (String footprint)
{
   try
   {
      Configuration configuration = new GMLConfiguration ();
      Parser parser = new Parser (configuration);

      Geometry geom =
            (Geometry) parser.parse (new InputSource (
                  new StringReader (footprint)));
      if (!geom.isEmpty() && !geom.isValid())
      {
         LOGGER.error("Wrong footprint");
         return false;
      }
   }
   catch (Exception e)
   {
      LOGGER.error("Error in extracted footprint: " + e.getMessage());
      return false;
   }
   return true;
}
 
开发者ID:SentinelDataHub,项目名称:dhus-core,代码行数:27,代码来源:ProcessingUtils.java

示例4: checkGMLFootprint

import org.geotools.xml.Parser; //导入方法依赖的package包/类
/**
 * Check GML Footprint validity
 */
private boolean checkGMLFootprint (String footprint)
{
   try
   {
      Configuration configuration = new GMLConfiguration ();
      Parser parser = new Parser (configuration);
      parser.parse (new InputSource (new StringReader (footprint)));         
      return true;
   }
   catch (Exception e)
   {
      LOGGER.error("Error in extracted footprint: " + e.getMessage());
      return false;
   }
}
 
开发者ID:SentinelDataHub,项目名称:DataHubSystem,代码行数:19,代码来源:ProcessingManager.java

示例5: parseGML3

import org.geotools.xml.Parser; //导入方法依赖的package包/类
/**
 * Parses GML3 without specifying a schema location.
 */
public static void parseGML3() throws Exception {
    InputStream in = GMLParsing.class.getResourceAsStream( "states.xml");
    GMLConfiguration gml = new GMLConfiguration();
    Parser parser = new Parser(gml);
    parser.setStrict(false);
    
    FeatureCollection features = (FeatureCollection) parser.parse(in);
    FeatureIterator i = features.features();
    
    int nfeatures = 0;
    while( i.hasNext() ) {
        SimpleFeature f = (SimpleFeature) i.next();
        System.out.println(f.getID());
        nfeatures++;
    }
    
    System.out.println("Number of features: " + nfeatures);
}
 
开发者ID:ianturton,项目名称:geotools-cookbook,代码行数:22,代码来源:GMLParsing.java

示例6: schemaParseGML3

import org.geotools.xml.Parser; //导入方法依赖的package包/类
/**
 * Parses GML3 by specifying the schema location.
 * <p>
 * This example first transforms the original file states.xml, and sets its
 * schemaLocation to the states.xsd file.
 * </p>
 */
public static void schemaParseGML3() throws Exception {
    File xml = setSchemaLocation();
    InputStream in = new FileInputStream(xml);
    
    GMLConfiguration gml = new GMLConfiguration();
    Parser parser = new Parser(gml);
    parser.setStrict(false);
    
    FeatureCollection features = (FeatureCollection) parser.parse(in);
    FeatureIterator i = features.features();
    
    int nfeatures = 0;
    while( i.hasNext() ) {
        SimpleFeature f = (SimpleFeature) i.next();
        System.out.println(f.getID());
        nfeatures++;
    }
    
    System.out.println("Number of features: " + nfeatures);
}
 
开发者ID:ianturton,项目名称:geotools-cookbook,代码行数:28,代码来源:GMLParsing.java

示例7: parseAndInsert

import org.geotools.xml.Parser; //导入方法依赖的package包/类
public void parseAndInsert() throws Exception {
	KMLConfiguration configuration = new KMLConfiguration();
	Parser parser = new Parser(configuration);
	StringReader reader = new StringReader(kml);
	SimpleFeature root = (SimpleFeature) parser.parse(reader);
	List<SimpleFeature> features = collect(root);
	for (SimpleFeature feature : features) {
		String name1 = (String) feature.getAttribute("NAME_0");
		String name2 = (String) feature.getAttribute("NAME_1");
		String name3 = (String) feature.getAttribute("NAME_2");
		String name = (String) feature.getAttribute("name");
		String code = (String) feature.getAttribute("HASC_2");
		if (name1 != null && name2 != null && name3 != null)
			name = name1 + " - " + name2 + " - " + name3;
		String subKml = getNextKml();
		insertLocation(name, code, subKml);
	}
}
 
开发者ID:GreenDelta,项目名称:olca-modules,代码行数:19,代码来源:MultiKmlImport.java

示例8: parseRequest

import org.geotools.xml.Parser; //导入方法依赖的package包/类
public static Object parseRequest(Parser parser, Reader reader, WFSInfo wfs) throws Exception {
    //set the input source with the correct encoding
    InputSource source = new InputSource(reader);
    source.setEncoding(wfs.getGeoServer().getSettings().getCharset());

    return parser.parse(source);
}
 
开发者ID:STEMLab,项目名称:geoserver-3d-extension,代码行数:8,代码来源:WFSXmlUtils_ISO.java

示例9: read

import org.geotools.xml.Parser; //导入方法依赖的package包/类
public Object read(Object request, Reader reader, Map kvp) throws Exception {
    //TODO: refactor this method to use WFSXmlUtils
    Catalog catalog = geoServer.getCatalog();

    //check the strict flag to determine if we should validate or not
    Boolean strict = (Boolean) kvp.get("strict");
    if ( strict == null ) {
        strict = Boolean.FALSE;
    }
    
    //create the parser instance
    Parser parser = new Parser(configuration);
    parser.setEntityResolver(entityResolverProvider.getEntityResolver());
    
    //"inject" namespace mappings
    parser.getNamespaces().add(new CatalogNamespaceSupport(catalog));

    //set validation based on strict or not
    parser.setValidating(strict.booleanValue());
    WFSURIHandler.addToParser(geoServer, parser);

    //parse
    Object parsed = parser.parse(reader); 
    
    //if strict was set, check for validation errors and throw an exception 
    if (strict.booleanValue() && !parser.getValidationErrors().isEmpty()) {
        WFSException exception = new WFSException("Invalid request", "InvalidParameterValue");

        for (Iterator e = parser.getValidationErrors().iterator(); e.hasNext();) {
            Exception error = (Exception) e.next();
            exception.getExceptionText().add(error.getLocalizedMessage());
        }

        throw exception;
    }
    
    return parsed;
}
 
开发者ID:STEMLab,项目名称:geoserver-3d-extension,代码行数:39,代码来源:WfsXmlReader_ISO.java

示例10: parseWfs

import org.geotools.xml.Parser; //导入方法依赖的package包/类
@Override
   protected Object parseWfs(InputStream is) throws IOException, SAXException, ParserConfigurationException {
	try {
		Parser parser = new Parser(m_configuration);
		return parser.parse(is);
	} finally {
		is.close();
	}
}
 
开发者ID:xandris,项目名称:geoserver-sync,代码行数:10,代码来源:GeoserverClientSynchronizer.java


注:本文中的org.geotools.xml.Parser.parse方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。