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


Java CRS类代码示例

本文整理汇总了Java中org.geotools.referencing.CRS的典型用法代码示例。如果您正苦于以下问题:Java CRS类的具体用法?Java CRS怎么用?Java CRS使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: expandBounds

import org.geotools.referencing.CRS; //导入依赖的package包/类
/**
 * Expands inBounds by multiplying min of inBounds.getWidth and inBounds.getHeight times percent
 * 
 * @param inBounds
 * @param percent
 * @return
 */
public static Bounds expandBounds(Bounds inBounds, String inCRS, double percent) {

	try {
		double ulx = inBounds.getLeft();
		double uly = inBounds.getTop();
		double lrx = inBounds.getRight();
		double lry = inBounds.getBottom();

		CoordinateReferenceSystem theCRS = CRS.decode(inCRS);
		ReferencedEnvelope re = new ReferencedEnvelope(ulx, lrx, lry, uly, theCRS);
		double expandBy = Math.min(re.getHeight(), re.getWidth()) * percent;
		re.expandBy(expandBy);
		return getBounds(re.toBounds(theCRS));

	} catch (Exception e) {
	}

	return null;
}
 
开发者ID:lizardtechblog,项目名称:ExpressZip,代码行数:27,代码来源:MapModel.java

示例2: execute

import org.geotools.referencing.CRS; //导入依赖的package包/类
@DescribeResult(name = "result", description = "Clipped feature collection")
public SimpleFeatureCollection execute(
        @DescribeParameter(name = "features", description = "Input feature collection") SimpleFeatureCollection features,
        @DescribeParameter(name = "clip", description = "Geometry to use for clipping (in same CRS as input features)") Geometry clip,
        @DescribeParameter(name = "preserveZ", min=0,description = "Attempt to preserve Z values from the original geometry (interpolate value for new points)") Boolean preserveZ)
        throws ProcessException {
    // only get the geometries in the bbox of the clip
    Envelope box = clip.getEnvelopeInternal();
    String srs = null;
    if(features.getSchema().getCoordinateReferenceSystem() != null) {
        srs = CRS.toSRS(features.getSchema().getCoordinateReferenceSystem());
    }
    BBOX bboxFilter = ff.bbox("", box.getMinX(), box.getMinY(), box.getMaxX(), box.getMaxY(), srs);
    
    // default value for preserve Z
    if(preserveZ == null) {
        preserveZ = false;
    }
    
    // return dynamic collection clipping geometries on the fly
    return new ClippingFeatureCollection(features.subCollection(bboxFilter), clip, preserveZ);
}
 
开发者ID:ec-europa,项目名称:sumo,代码行数:23,代码来源:ClipProcess.java

示例3: parse

import org.geotools.referencing.CRS; //导入依赖的package包/类
@Override
public Object parse(ElementInstance instance, Node node, Object value) throws Exception {
    Envelope envelope = (Envelope) super.parse(instance, node, value);

    // handle the box CRS
    CoordinateReferenceSystem crs = this.crs;
    if (node.hasAttribute("srsName")) {
        URI srs = (URI) node.getAttributeValue("srsName");
        crs = CRS.decode(srs.toString());
    }
    
    if(crs != null) {
        return ReferencedEnvelope.create(envelope, crs);
    } else {
        return envelope;
    }
}
 
开发者ID:STEMLab,项目名称:geoserver-3d-extension,代码行数:18,代码来源:GMLBoxTypeBinding_ISO.java

示例4: RasterizedSpatialiteLasLayer

import org.geotools.referencing.CRS; //导入依赖的package包/类
public RasterizedSpatialiteLasLayer( String title, ASpatialDb db, Integer tileSize, boolean transparentBackground,
        boolean doIntensity ) throws Exception {
    super(makeLevels(title, tileSize, transparentBackground, db, doIntensity));
    String plus = doIntensity ? INTENSITY : ELEVATION;
    this.layerName = title + " " + plus;
    this.setUseTransparentTextures(true);

    try {
        Envelope tableBounds = db.getTableBounds(LasSourcesTable.TABLENAME);
        GeometryColumn spatialiteGeometryColumns = db.getGeometryColumnsForTable(LasCellsTable.TABLENAME);
        CoordinateReferenceSystem dataCrs = CRS.decode("EPSG:" + spatialiteGeometryColumns.srid);
        CoordinateReferenceSystem targetCRS = DefaultGeographicCRS.WGS84;
        ReferencedEnvelope env = new ReferencedEnvelope(tableBounds, dataCrs);
        ReferencedEnvelope envLL = env.transform(targetCRS, true);

        centre = envLL.centre();
    } catch (Exception e) {
        e.printStackTrace();
        centre = CrsUtilities.WORLD.centre();
    }
}
 
开发者ID:TheHortonMachine,项目名称:hortonmachine,代码行数:22,代码来源:RasterizedSpatialiteLasLayer.java

示例5: getPixelFromGeo

import org.geotools.referencing.CRS; //导入依赖的package包/类
/**
 * Computes the subpixel (i.e. precision greater than integer) location of a map coordinates
 * @param xgeo is the longitude
 * @param ygeo is the latitude
 * @param inputEpsgProjection is the projection system of (xgeo, ygeo) (for instance "EPSG:4326"). if null use the original projection
 * @return [xpixel, ypixel]
 *
 */
public double[] getPixelFromGeo(double xgeo, double ygeo, String inputEpsgProjection) {
	double[] out = new double[]{xgeo, ygeo};
    if (inputEpsgProjection != null) {
        try {
            double[] temp = new double[]{xgeo, ygeo, 0};
            CoordinateReferenceSystem crs = CRS.decode(inputEpsgProjection);
            MathTransform math = CRS.findMathTransform(crs, sourceCRS);
            math.transform(temp, 0, temp, 0, 1);
            out[0] = temp[0];
            out[1] = temp[1];
        } catch (Exception ex) {
        	logger.error(ex.getMessage(),ex);
        }
    }
    geo2pix.transform(out, 0, out, 0, 1);
    out[0] = out[0];
    out[1] = out[1];
    return out;
}
 
开发者ID:ec-europa,项目名称:sumo,代码行数:28,代码来源:GcpsGeoTransform.java

示例6: getGeoFromPixel

import org.geotools.referencing.CRS; //导入依赖的package包/类
/**
   * Computes the map coordinates given the pixel location in the image reference
   * @param xpix the pixel location in x
   * @param ypix the pixel location in y
   * @param outputEpsgProjection is the projection system of the result (for instance "EPSG:4326")  if null use the original projection
   * @return [longitude, latitude]
   * 
   * 
   */
  public double[] getGeoFromPixel(double xpix, double ypix, String outputEpsgProjection) {
  	double[] out = new double[2];
pix2geo.transform(new double[]{xpix , ypix }, 0, out, 0, 1);
      //pix2geo.transform(new double[]{xpix + m_translationX, ypix + m_translationY}, 0, out, 0, 1);
      if (outputEpsgProjection != null) {
          try {
              double[] temp = new double[3];
              CoordinateReferenceSystem crs = CRS.decode(outputEpsgProjection);
              MathTransform math = CRS.findMathTransform(sourceCRS, crs);
              math.transform(new double[]{out[0], out[1], 0}, 0, temp, 0, 1);
              out[0] = temp[0];
              out[1] = temp[1];
          } catch (Exception ex) {
          	logger.error(ex.getMessage(),ex);
          }
      }
      return out;
  }
 
开发者ID:ec-europa,项目名称:sumo,代码行数:28,代码来源:GcpsGeoTransform.java

示例7: getPixelFromGeo

import org.geotools.referencing.CRS; //导入依赖的package包/类
/**
 * 
 */
public double[] getPixelFromGeo(double xgeo, double ygeo, String inputEpsgProjection) {
    double[] out = new double[]{xgeo, ygeo};
    if (inputEpsgProjection != null) {
        try {
            double[] temp = new double[]{xgeo, ygeo, 0};
            CoordinateReferenceSystem crs = CRS.decode(inputEpsgProjection);
            MathTransform math = CRS.findMathTransform(crs, sourceCRS);
            math.transform(temp, 0, temp, 0, 1);
            out[0] = temp[0];
            out[1] = temp[1];
        } catch (Exception ex) {
        	logger.error(ex.getMessage(),ex);
        }
    }
    geo2pix.transform(out, 0, out, 0, 1);
    return out;
}
 
开发者ID:ec-europa,项目名称:sumo,代码行数:21,代码来源:AffineGeoTransform.java

示例8: getGeoFromPixel

import org.geotools.referencing.CRS; //导入依赖的package包/类
public double[] getGeoFromPixel(double xpix, double ypix, String outputEpsgProjection) {
    double[] out = new double[2];
    pix2geo.transform(new double[]{xpix, ypix}, 0, out, 0, 1);
    if (outputEpsgProjection != null) {
        try {
            double[] temp = new double[3];
            CoordinateReferenceSystem crs = CRS.decode(outputEpsgProjection);
            MathTransform math = CRS.findMathTransform(sourceCRS, crs);
            math.transform(new double[]{out[0], out[1], 0}, 0, temp, 0, 1);
            out[0] = temp[0];
            out[1] = temp[1];
        } catch (Exception ex) {
        	logger.error(ex.getMessage(),ex);
        }
    }
    return out;
}
 
开发者ID:ec-europa,项目名称:sumo,代码行数:18,代码来源:AffineGeoTransform.java

示例9: merge

import org.geotools.referencing.CRS; //导入依赖的package包/类
private Optional<ReferencedEnvelope> merge(final ReferencedEnvelope oldEnv,
        final Collection<ReferencedEnvelope> dirtyList) {
    final CoordinateReferenceSystem declaredCrs = oldEnv.getCoordinateReferenceSystem();
    return dirtyList.stream()
        .map(env->{
            if(env instanceof ReferencedEnvelope3D) {
                return new ReferencedEnvelope(env, CRS.getHorizontalCRS(env.getCoordinateReferenceSystem()));
            } else  {
                return env;
            }
        })
        .map(env->{
            try {
                return env.transform(declaredCrs, true, 1000);
            } catch (TransformException | FactoryException e) {
                throw new RuntimeException("Error while merging bounding boxes",e);
            }
        })
        .reduce((env1, env2)->{ReferencedEnvelope x = new ReferencedEnvelope(env1); x.expandToInclude(env2); return x;});
}
 
开发者ID:MapStory,项目名称:ms-gs-plugins,代码行数:21,代码来源:BoundsUpdateTransactionListener.java

示例10: getDeclaredCrs

import org.geotools.referencing.CRS; //导入依赖的package包/类
/**
 * Returns the declared CRS given the native CRS and the request WFS version
 * 
 * @param nativeCRS
 * @param wfsVersion
 *
 */
public static CoordinateReferenceSystem getDeclaredCrs(CoordinateReferenceSystem nativeCRS,
        String wfsVersion) {
    try {
        if(nativeCRS == null)
            return null;
        
        if (wfsVersion.equals("1.0.0")) {
            return nativeCRS;
        } else {
            String code = GML2EncodingUtils.epsgCode(nativeCRS);
            //it's possible that we can't do the CRS -> code -> CRS conversion...so we'll just return what we have
            if (code == null) return nativeCRS;
            return CRS.decode("urn:x-ogc:def:crs:EPSG:6.11.2:" + code);
        }
    } catch (Exception e) {
        throw new WFSException("We have had issues trying to flip axis of " + nativeCRS, e);
    }
}
 
开发者ID:STEMLab,项目名称:geoserver-3d-extension,代码行数:26,代码来源:WFSReprojectionUtil_ISO.java

示例11: toShapeFile

import org.geotools.referencing.CRS; //导入依赖的package包/类
/**
 * write a shapefile representing the grid in a coordinate ref system ex :
 * "EPSG:2975" -> RGR92, "EPSG:2154" -> L93, "EPSG:4326" -> WGS84
 * 
 * @param fileName
 * @param epsg
 */
public void toShapeFile(String fileName, String epsg) {
    FT_FeatureCollection<IFeature> pop = new FT_FeatureCollection<>();
    System.out.println("writing..." + fileName);
    for (int i = 0; i < nbRows(); ++i)
        for (int j = 0; j < nbCols(); ++j)
            pop.add(new DefaultFeature(tiles[i][j]));

    CRSAuthorityFactory factory = CRS.getAuthorityFactory(true);
    CoordinateReferenceSystem crs = null;
    try {
        crs = factory.createCoordinateReferenceSystem(epsg);
    } catch (FactoryException e) {
        e.printStackTrace();
    }
    ShapefileWriter.write(pop, fileName, crs);
    System.out.println("writing done");
}
 
开发者ID:IGNF,项目名称:geoxygene,代码行数:25,代码来源:Grid.java

示例12: compareCarteRecale

import org.geotools.referencing.CRS; //导入依赖的package包/类
/**
 * 
 * @param reseauRecale1
 * @param reseauRecale2
 * @throws Exception
 */
private void compareCarteRecale(CarteTopo reseauRecale1,  CarteTopo reseauRecale2) throws Exception {

    CoordinateReferenceSystem sourceCRS = CRS.decode("EPSG:4326");
    
    GML encode = new GML(Version.WFS1_0);
    encode.setNamespace("geotools", "http://geotools.org");
    
    // Arcs recales du reseau 1
    SimpleFeatureCollection arcs1 = GeOxygeneGeoToolsTypes.convert2FeatureCollection(reseauRecale1.getPopArcs(), sourceCRS);
    ByteArrayOutputStream output1 = new ByteArrayOutputStream();
    encode.encode(output1, arcs1);
    
    // Arcs recales du reseau 2
    SimpleFeatureCollection arcs2 = GeOxygeneGeoToolsTypes.convert2FeatureCollection(reseauRecale2.getPopArcs(), sourceCRS);
    ByteArrayOutputStream output2 = new ByteArrayOutputStream();
    encode.encode(output2, arcs2);
    
    // On compare : est-ce que le XML est comparable ????
    assertXMLEqual(output1.toString(), output2.toString());
}
 
开发者ID:IGNF,项目名称:geoxygene,代码行数:27,代码来源:ITRecalageAppariement.java

示例13: initialise

import org.geotools.referencing.CRS; //导入依赖的package包/类
/**
 * Initialise the WKTParser object.
 */
private static void initialise() {
    Hints hints = new Hints(Hints.CRS, DefaultGeographicCRS.WGS84);

    PositionFactory positionFactory = GeometryFactoryFinder.getPositionFactory(hints);
    GeometryFactory geometryFactory = GeometryFactoryFinder.getGeometryFactory(hints);
    PrimitiveFactory primitiveFactory = GeometryFactoryFinder.getPrimitiveFactory(hints);
    AggregateFactory aggregateFactory = GeometryFactoryFinder.getAggregateFactory(hints);

    wktParser = new WKTParser(geometryFactory, primitiveFactory, positionFactory,
            aggregateFactory);

    wktTypeList.add(new WKTType(WKT_POINT, false, 1, "Point", false, false));
    wktTypeList.add(new WKTType(WKT_MULTIPOINT, true, 1, "Point", true, false));
    wktTypeList.add(new WKTType(WKT_LINESTRING, false, 2, "Line", false, false));
    wktTypeList.add(new WKTType("LINEARRING", false, 2, "Line", false, false));
    wktTypeList.add(new WKTType(WKT_MULTILINESTRING, true, 2, "Line", true, false));
    wktTypeList.add(new WKTType(WKT_POLYGON, false, -1, "Polygon", false, true));
    wktTypeList.add(new WKTType(WKT_MULTIPOLYGON, true, -1, "Polygon", true, true));

    for (WKTType wkyType : wktTypeList) {
        wktTypeMap.put(wkyType.getName(), wkyType);
    }
}
 
开发者ID:robward-scisys,项目名称:sldeditor,代码行数:27,代码来源:WKTConversion.java

示例14: decode

import org.geotools.referencing.CRS; //导入依赖的package包/类
/**
 * Decodes a given code to a {@link org.opengis.referencing.crs.CompoundCRS}
 * @param code the code
 * @return the compound CRS
 * @throws FactoryException if the code does not represent a compound CRS
 * or if one of its components could not be decoded
 */
public static CoordinateReferenceSystem decode(String code) throws FactoryException {
  code = code.trim();
  if (!isCompound(code)) {
    throw new NoSuchAuthorityCodeException("No compound CRS", AUTHORITY, code);
  }
  
  code = code.substring(PREFIX.length());
  String[] parts = code.split(",");
  CoordinateReferenceSystem[] crss = new CoordinateReferenceSystem[parts.length];
  for (int i = 0; i < crss.length; ++i) {
    crss[i] = CRS.decode(AUTHORITY + ":" + parts[i].trim());
  }
  
  return new DefaultCompoundCRS("", crss);
}
 
开发者ID:georocket,项目名称:georocket,代码行数:23,代码来源:CompoundCRSDecoder.java

示例15: setExtend

import org.geotools.referencing.CRS; //导入依赖的package包/类
private void setExtend(Double x1, Double x2, Double y1, Double y2, String
        crs) {
    CoordinateReferenceSystem coordinateReferenceSystem = null;
    try {
        coordinateReferenceSystem = CRS.decode(crs);
        ReferencedEnvelope initExtend =
                new ReferencedEnvelope(x1,
                        x2,
                        y1,
                        y2, coordinateReferenceSystem);
        setExtend(initExtend);
    } catch (FactoryException e) {
        log.log(Level.SEVERE, e.getMessage(), e);
    }

}
 
开发者ID:gdi-by,项目名称:downloadclient,代码行数:17,代码来源:WMSMapSwing.java


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