本文整理汇总了Java中org.geojson.FeatureCollection类的典型用法代码示例。如果您正苦于以下问题:Java FeatureCollection类的具体用法?Java FeatureCollection怎么用?Java FeatureCollection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FeatureCollection类属于org.geojson包,在下文中一共展示了FeatureCollection类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: printGeoJson
import org.geojson.FeatureCollection; //导入依赖的package包/类
public byte[] printGeoJson(final AreaPrintRequestDTO dto,
final FeatureCollection featureCollection) {
final long zoomLayer = zoomLayer(featureCollection.getBbox(), dto.getPaperDpi());
final String url = UriComponentsBuilder.fromUri(runtimeEnvironmentUtil.getMapExportEndpoint())
.path(String.format("/%s%s/%d/%s%d.pdf",
dto.getPaperSize().name(),
dto.getPaperOrientation().asLetter(),
dto.getPaperDpi(),
LAYER_NAME,
zoomLayer))
.build()
.toUri()
.toASCIIString();
final HttpHeaders requestHeaders = new HttpHeaders();
requestHeaders.setAccept(Collections.singletonList(MediaTypeExtras.APPLICATION_PDF));
requestHeaders.setContentType(MediaType.APPLICATION_JSON);
requestHeaders.set("Accept-Encoding", "gzip");
final HttpEntity<FeatureCollection> requestEntity = new HttpEntity<>(featureCollection, requestHeaders);
return restTemplate.exchange(url, HttpMethod.POST, requestEntity, byte[].class).getBody();
}
开发者ID:suomenriistakeskus,项目名称:oma-riista-web,代码行数:25,代码来源:AreaPrintFeature.java
示例2: toFeatureCollectionWithMetadata
import org.geojson.FeatureCollection; //导入依赖的package包/类
private FeatureCollection toFeatureCollectionWithMetadata(final AreaEntity<?> area,
final HuntingClub club,
final int huntingYear) {
return area.computeCombinedFeatures(zoneRepository, 1)
.map(featureCollection -> {
final Date saveDate = area.getLatestCombinedModificationTime();
final DateTime saveDateTime = new DateTime(saveDate).withZone(DateTimeZone.UTC);
for (final Feature feature : featureCollection) {
feature.setId(null);
feature.setProperty(GeoJSONConstants.PROPERTY_CLUB_NAME, club.getNameLocalisation());
feature.setProperty(GeoJSONConstants.PROPERTY_AREA_NAME, area.getNameLocalisation());
feature.setProperty(GeoJSONConstants.PROPERTY_AREA_SIZE, Math.round(area.getZone().getComputedAreaSize()));
feature.setProperty(GeoJSONConstants.PROPERTY_WATER_AREA_SIZE, Math.round(area.getZone().getWaterAreaSize()));
feature.setProperty(GeoJSONConstants.PROPERTY_SAVE_DATE, ISODateTimeFormat.basicDateTimeNoMillis().print(saveDateTime));
feature.setProperty(GeoJSONConstants.PROPERTY_HUNTING_YEAR, huntingYear);
}
return featureCollection;
})
.orElseThrow(MissingHuntingClubAreaGeometryException::new);
}
开发者ID:suomenriistakeskus,项目名称:oma-riista-web,代码行数:24,代码来源:HuntingClubAreaExportFeature.java
示例3: geoJSON
import org.geojson.FeatureCollection; //导入依赖的package包/类
@Transactional(readOnly = true, timeout = 60)
public FeatureCollection geoJSON(final long clubAreaId) {
final HuntingClubArea huntingClubArea = requireEntityService
.requireHuntingClubArea(clubAreaId, EntityPermission.READ);
if (huntingClubArea.getZone() != null) {
final GISZone gisZone = huntingClubArea.getZone();
final FeatureCollection features = zoneRepository.getPalstaFeatures(gisZone.getId(), GISUtils.SRID.WGS84);
features.setBbox(zoneRepository.getBounds(gisZone.getId(), GISUtils.SRID.WGS84));
final Optional<Feature> excludedFeature = gisZone.getExcludedAsGeoJSON(GeoJSONConstants.ID_EXCLUDED);
excludedFeature.ifPresent(features::add);
// Metsähallitus hirvialueet
features.addAll(metsahallitusRepository.listZoneHirviFeatures(gisZone.getId(), GISUtils.SRID.WGS84));
return features;
}
return new FeatureCollection();
}
开发者ID:suomenriistakeskus,项目名称:oma-riista-web,代码行数:21,代码来源:HuntingClubAreaZoneFeature.java
示例4: updateGeoJSON
import org.geojson.FeatureCollection; //导入依赖的package包/类
@Transactional(timeout = 60)
public long updateGeoJSON(final long clubAreaId, final FeatureCollection featureCollection) {
final HuntingClubArea huntingClubArea = requireEntityService
.requireHuntingClubArea(clubAreaId, EntityPermission.UPDATE);
final GISZone zone = huntingClubArea.getZone() != null ? huntingClubArea.getZone() : new GISZone();
zone.setExcludedGeom(extractExcludedFeature(featureCollection));
zone.setMetsahallitusHirvi(extractMetsahallitusHirvi(featureCollection));
zone.setComputedAreaSize(-1);
zone.setWaterAreaSize(-1);
huntingClubArea.setZone(zone);
// Make sure modification time is updated
zone.setModificationTimeToCurrentTime();
huntingClubArea.setModificationTimeToCurrentTime();
zoneRepository.saveAndFlush(zone);
zoneRepository.updatePalstaFeatures(zone.getId(), featureCollection);
return zone.getId();
}
开发者ID:suomenriistakeskus,项目名称:oma-riista-web,代码行数:23,代码来源:HuntingClubAreaZoneFeature.java
示例5: findPermitArea
import org.geojson.FeatureCollection; //导入依赖的package包/类
@Transactional(readOnly = true)
public FeatureCollection findPermitArea(final long harvestPermitId,
final int huntingYear,
final int gameSpeciesCode) {
final GameSpecies species = gameDiaryService.getGameSpeciesByOfficialCode(gameSpeciesCode);
final HarvestPermit harvestPermit =
requireEntityService.requireHarvestPermit(harvestPermitId, EntityPermission.READ);
if (!harvestPermit.isMooselikePermitType()) {
return new FeatureCollection();
}
final Map<Long, Map<String, Object>> permitZones = getPermitZones(harvestPermit, huntingYear, species);
final FeatureCollection combinedFeatures = zoneRepository.getCombinedFeatures(
permitZones.keySet(), GISUtils.SRID.WGS84, SIMPLIFY_AMOUNT);
combinedFeatures.forEach(feature -> {
final long zoneId = Long.parseLong(feature.getId());
Optional.ofNullable(permitZones.get(zoneId))
.ifPresent(props -> feature.getProperties().putAll(props));
});
return combinedFeatures;
}
开发者ID:suomenriistakeskus,项目名称:oma-riista-web,代码行数:26,代码来源:SharedPermitMapFeature.java
示例6: main
import org.geojson.FeatureCollection; //导入依赖的package包/类
public static void main(String[] args) {
final ObjectMapper objectMapper = new ObjectMapper();
final Path source = Paths.get(System.getenv("HOME") + "/area.json");
final Path target = Paths.get(System.getenv("HOME") + "/gmapsupp.mp");
try (final InputStream is = new FileInputStream(source.toFile());
final BufferedInputStream bis = new BufferedInputStream(is)) {
final HuntingClubAreaDTO area = new HuntingClubAreaDTO();
area.setId(1L);
area.setNameFI("omariista");
final FeatureCollection featureCollection = objectMapper.readValue(bis, FeatureCollection.class);
final String content = new GarminPolishFormatConverter(featureCollection, area).export();
System.out.println(content);
Files.write(target, content.getBytes(StandardCharsets.ISO_8859_1));
} catch (IOException e) {
e.printStackTrace();
}
}
开发者ID:suomenriistakeskus,项目名称:oma-riista-web,代码行数:23,代码来源:GarminPolishFormatConverter.java
示例7: PalstaFeatureCollection
import org.geojson.FeatureCollection; //导入依赖的package包/类
public PalstaFeatureCollection(final FeatureCollection featureCollection,
final List<Integer> currentList) {
this.current = Ints.toArray(currentList);
final List<Feature> palstaFeatures = featureCollection.getFeatures().stream()
.filter(f -> f.getId() != null && DIGIT_MATCHER.matchesAllOf(f.getId()))
.collect(toList());
this.toRetain = palstaFeatures.stream()
.mapToInt(f -> Integer.parseInt(f.getId()))
.toArray();
this.toReplace = palstaFeatures.stream()
.filter(f -> Boolean.TRUE.equals(f.getProperty(GeoJSONConstants.PROPERTY_FIXED)))
.mapToInt(f -> Integer.parseInt(f.getId()))
.toArray();
}
开发者ID:suomenriistakeskus,项目名称:oma-riista-web,代码行数:18,代码来源:PalstaFeatureCollection.java
示例8: execute
import org.geojson.FeatureCollection; //导入依赖的package包/类
@Nonnull
public FeatureCollection execute(final Set<Long> zoneIds, final GISUtils.SRID srid, final double simplifyAmount) {
final FeatureCollection featureCollection = new FeatureCollection();
featureCollection.setCrs(srid.getGeoJsonCrs());
if (zoneIds.isEmpty()) {
return featureCollection;
}
final MapSqlParameterSource params = new MapSqlParameterSource()
.addValue("zoneIds", zoneIds)
.addValue("crs", srid.getValue())
.addValue("simplify", simplifyAmount);
final List<Feature> features = jdbcOperations.query(SQL, params, (rs, i) -> mapResultToFeature(rs));
if (features != null) {
featureCollection.setFeatures(features);
}
return featureCollection;
}
开发者ID:suomenriistakeskus,项目名称:oma-riista-web,代码行数:23,代码来源:GetCombinedFeatureCollectionQuery.java
示例9: execute
import org.geojson.FeatureCollection; //导入依赖的package包/类
public FeatureCollection execute(final long zoneId, final GISUtils.SRID srid) {
final MapSqlParameterSource params = new MapSqlParameterSource()
.addValue("zoneId", zoneId)
.addValue("crs", srid.getValue());
final List<Feature> features = jdbcOperations.query(SQL, params, (resultSet, i) -> {
final Feature feature = new Feature();
feature.setId(Long.toString(zoneId));
feature.setProperty(GeoJSONConstants.PROPERTY_NUMBER, resultSet.getString("property_identifier"));
feature.setGeometry(GISUtils.parseGeoJSONGeometry(objectMapper, resultSet.getString("geom")));
return feature;
});
final FeatureCollection featureCollection = new FeatureCollection();
if (features != null) {
featureCollection.setFeatures(features);
}
return featureCollection;
}
开发者ID:suomenriistakeskus,项目名称:oma-riista-web,代码行数:23,代码来源:GetExternalFeatureCollectionQuery.java
示例10: print
import org.geojson.FeatureCollection; //导入依赖的package包/类
@RequestMapping(value = "/{id:\\d+}/print",
method = RequestMethod.POST,
consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
public ResponseEntity<?> print(@PathVariable final long id,
@ModelAttribute @Valid final AreaPrintRequestDTO dto) {
try {
final Locale locale = LocaleContextHolder.getLocale();
final FeatureCollection featureCollection = huntingClubAreaPrintFeature.exportClubAreaFeatures(id, locale);
final String filename = huntingClubAreaPrintFeature.getClubAreaExportFileName(id, locale);
final byte[] imageData = huntingClubAreaPrintFeature.printGeoJson(dto, featureCollection);
final MediaType mediaType = MediaTypeExtras.APPLICATION_PDF;
return ResponseEntity.ok()
.contentType(mediaType)
.contentLength(imageData.length)
.header(ContentDispositionUtil.HEADER_NAME, ContentDispositionUtil.encodeAttachmentFilename(filename))
.body(imageData);
} catch (final Exception ex) {
LOG.error("Club area map export for printing has failed", ex);
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
.body("Kartan tulostus epäonnistui. Yritä myöhemmin uudelleen");
}
}
开发者ID:suomenriistakeskus,项目名称:oma-riista-web,代码行数:27,代码来源:ClubAreaApiResource.java
示例11: print
import org.geojson.FeatureCollection; //导入依赖的package包/类
@RequestMapping(value = "/{id:\\d+}/print",
method = RequestMethod.POST,
consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
public ResponseEntity<?> print(@PathVariable final long id,
@ModelAttribute @Valid final AreaPrintRequestDTO dto) {
try {
final Locale locale = LocaleContextHolder.getLocale();
final FeatureCollection featureCollection = huntingClubAreaPrintFeature.exportHarvestPermitAreaFeatures(id, locale);
final String filename = huntingClubAreaPrintFeature.getHarvestPermitAreaExportFileName(id, locale);
final byte[] imageData = huntingClubAreaPrintFeature.printGeoJson(dto, featureCollection);
final MediaType mediaType = MediaTypeExtras.APPLICATION_PDF;
return ResponseEntity.ok()
.contentType(mediaType)
.contentLength(imageData.length)
.header(ContentDispositionUtil.HEADER_NAME, ContentDispositionUtil.encodeAttachmentFilename(filename))
.body(imageData);
} catch (final Exception ex) {
LOG.error("Permit area map export for printing has failed", ex);
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
.body("Kartan tulostus epäonnistui. Yritä myöhemmin uudelleen");
}
}
开发者ID:suomenriistakeskus,项目名称:oma-riista-web,代码行数:27,代码来源:HarvestPermitAreaApiResource.java
示例12: build
import org.geojson.FeatureCollection; //导入依赖的package包/类
public BoundedDataSet build(final GeoJsonObject data) {
dataSet = new DataSet();
if (data instanceof FeatureCollection) {
processFeatureCollection((FeatureCollection) data);
} else if (data instanceof GeometryCollection) {
processGeometryCollection(null, (GeometryCollection) data);
} else if (data instanceof Feature) {
processFeature((Feature) data);
} else {
processGeometry(null, data);
}
Bounds bounds = null;
for (OsmPrimitive osmPrimitive : dataSet.allPrimitives()) {
bounds = mergeBounds(bounds, osmPrimitive);
}
return new BoundedDataSet(dataSet, bounds);
}
开发者ID:JOSM,项目名称:geojson,代码行数:20,代码来源:DataSetBuilder.java
示例13: report
import org.geojson.FeatureCollection; //导入依赖的package包/类
@Transactional(readOnly = true)
public FeatureCollection report(int year) {
if (year < MIN_YEAR || year > MAX_YEAR) {
throw new IllegalArgumentException("Year must be between" + MIN_YEAR + " and " + MAX_YEAR);
}
List<Feature> features = jdbcTemplate.query(SQL, getSqlParameterSource(year, "209"), new RowMapper<Feature>() {
private final ObjectMapper objectMapper = new ObjectMapper();
@Override
public Feature mapRow(ResultSet rs, int rowNum) throws SQLException {
Feature feature = new Feature();
feature.getProperties().put("day", rs.getString("day"));
feature.getProperties().put("gender", rs.getString("gender"));
feature.getProperties().put("age", rs.getString("age"));
feature.getProperties().put("luke_status", rs.getString("luke_status"));
feature.getProperties().put("rhy_code", rs.getString("rhy_code"));
feature.getProperties().put("rhy_fi", rs.getString("rhy_fi"));
feature.getProperties().put("rhy_sv", rs.getString("rhy_sv"));
try {
feature.setGeometry(objectMapper.readValue(rs.getString("geom"), GeoJsonObject.class));
} catch (IOException e) {
throw new RuntimeException(e);
}
return feature;
}
});
FeatureCollection featureCollection = new FeatureCollection();
featureCollection.setFeatures(features);
Crs crs = new Crs();
crs.getProperties().put("name", "urn:ogc:def:crs:EPSG::3067");
featureCollection.setCrs(crs);
return featureCollection;
}
开发者ID:suomenriistakeskus,项目名称:oma-riista-web,代码行数:39,代码来源:PublicWolfReportFeature.java
示例14: exportClubAreaFeatures
import org.geojson.FeatureCollection; //导入依赖的package包/类
@Transactional(readOnly = true)
public FeatureCollection exportClubAreaFeatures(final long clubAreaId, final Locale locale) {
final HuntingClubArea huntingClubArea = requireEntityService
.requireHuntingClubArea(clubAreaId, EntityPermission.READ);
final GISZone zone = huntingClubArea.getZone();
if (zone == null) {
throw new MissingHuntingClubAreaGeometryException();
}
final LocalisedString areaName = huntingClubArea.getNameLocalisation();
final LocalisedString clubName = huntingClubArea.getClub().getNameLocalisation();
final Date modificationTime = huntingClubArea.getModificationTime();
return exportClubAreaFeatures(locale, zone, areaName, clubName, modificationTime);
}
开发者ID:suomenriistakeskus,项目名称:oma-riista-web,代码行数:16,代码来源:AreaPrintFeature.java
示例15: exportHarvestPermitAreaFeatures
import org.geojson.FeatureCollection; //导入依赖的package包/类
@Transactional(readOnly = true)
public FeatureCollection exportHarvestPermitAreaFeatures(final long permitAreaId, final Locale locale) {
final HarvestPermitArea harvestPermitArea = requireEntityService
.requireHarvestPermitArea(permitAreaId, EntityPermission.READ);
final GISZone zone = harvestPermitArea.getZone();
if (zone == null) {
throw new MissingHuntingClubAreaGeometryException();
}
final LocalisedString areaName = harvestPermitArea.getNameLocalisation();
final LocalisedString clubName = harvestPermitArea.getClub().getNameLocalisation();
final Date modificationTime = harvestPermitArea.getModificationTime();
return exportClubAreaFeatures(locale, zone, areaName, clubName, modificationTime);
}
开发者ID:suomenriistakeskus,项目名称:oma-riista-web,代码行数:16,代码来源:AreaPrintFeature.java
示例16: exportCombinedGeoJsonAsArchive
import org.geojson.FeatureCollection; //导入依赖的package包/类
@Transactional(readOnly = true)
public byte[] exportCombinedGeoJsonAsArchive(final long clubAreaId, final Locale locale) {
final HuntingClubArea clubArea = requireEntityService.requireHuntingClubArea(clubAreaId, EntityPermission.READ);
final FeatureCollection featureCollection =
toFeatureCollectionWithMetadata(clubArea, clubArea.getClub(), clubArea.getHuntingYear());
try (final ByteArrayOutputStream bos = new ByteArrayOutputStream();
final ZipOutputStream zip = new ZipOutputStream(bos, StandardCharsets.UTF_8)) {
zip.setComment("Exported from oma.riista.fi on " + DTF.print(DateUtil.now()));
zip.setLevel(9);
// GeoJSON
zip.putNextEntry(new ZipEntry(FILENAME_GEOJSON));
final OutputStreamWriter gos = new OutputStreamWriter(new CloseShieldOutputStream(zip), StandardCharsets.UTF_8);
objectMapper.writeValue(gos, featureCollection);
zip.closeEntry();
// Metadata
final OutputStreamWriter mos = new OutputStreamWriter(zip, StandardCharsets.UTF_8);
zip.putNextEntry(new ZipEntry(FILENAME_METADATA));
mos.write(exportMetadataString(clubArea, locale));
mos.flush();
zip.closeEntry();
zip.flush();
zip.close();
return bos.toByteArray();
} catch (IOException ioe) {
throw new RuntimeException(ioe);
}
}
开发者ID:suomenriistakeskus,项目名称:oma-riista-web,代码行数:35,代码来源:HuntingClubAreaExportFeature.java
示例17: extractExcludedFeature
import org.geojson.FeatureCollection; //导入依赖的package包/类
private static Geometry extractExcludedFeature(final FeatureCollection featureCollection) {
return featureCollection.getFeatures().stream()
.filter(f -> f.getGeometry() != null && GeoJSONConstants.ID_EXCLUDED.equals(f.getId()))
.findAny()
.map(f -> PolygonConversionUtil.geoJsonToJava(f.getGeometry(), GISUtils.SRID.WGS84))
.orElse(null);
}
开发者ID:suomenriistakeskus,项目名称:oma-riista-web,代码行数:8,代码来源:HuntingClubAreaZoneFeature.java
示例18: extractMetsahallitusHirvi
import org.geojson.FeatureCollection; //导入依赖的package包/类
private static Set<Integer> extractMetsahallitusHirvi(final FeatureCollection featureCollection) {
return featureCollection.getFeatures().stream()
.map(Feature::getId)
.filter(Objects::nonNull)
.filter(id -> id.startsWith(GeoJSONConstants.ID_PREFIX_MH_HIRVI))
.map(id -> id.substring(GeoJSONConstants.ID_PREFIX_MH_HIRVI.length()))
.map(Integer::parseInt)
.collect(Collectors.toSet());
}
开发者ID:suomenriistakeskus,项目名称:oma-riista-web,代码行数:10,代码来源:HuntingClubAreaZoneFeature.java
示例19: huntingAreaGeoJSON
import org.geojson.FeatureCollection; //导入依赖的package包/类
@Transactional(readOnly = true)
public FeatureCollection huntingAreaGeoJSON(final long huntingClubGroupId) {
final HuntingClubGroup group = requireGroup(huntingClubGroupId, EntityPermission.READ);
return Optional.ofNullable(group.getHuntingArea())
.flatMap(area -> area.computeCombinedFeatures(zoneRepository, SIMPLIFY_AMOUNT))
.orElseGet(FeatureCollection::new);
}
开发者ID:suomenriistakeskus,项目名称:oma-riista-web,代码行数:9,代码来源:GroupHuntingDiaryFeature.java
示例20: findOne
import org.geojson.FeatureCollection; //导入依赖的package包/类
@Transactional(readOnly = true, propagation = Propagation.MANDATORY, noRollbackFor = RuntimeException.class)
public FeatureCollection findOne(final Long id) {
final String sql = SELECT_ALL +
"FROM palstaalue a\n" +
"WHERE id = :id";
return query(sql, new MapSqlParameterSource().addValue("id", id));
}
开发者ID:suomenriistakeskus,项目名称:oma-riista-web,代码行数:9,代码来源:GISPropertyGeometryRepository.java
注:本文中的org.geojson.FeatureCollection类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论