本文整理汇总了Java中org.geojson.FeatureCollection类的典型用法代码示例。如果您正苦于以下问题:Java FeatureCollection类的具体用法?Java FeatureCollection怎么用?Java FeatureCollection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FeatureCollection类属于org.geojson包,在下文中一共展示了FeatureCollection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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();
}
示例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);
}
示例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();
}
示例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();
}
示例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;
}
示例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();
}
}
示例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();
}
示例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;
}
示例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;
}
示例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");
}
}
示例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");
}
}
示例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);
}
示例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;
}
示例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);
}
示例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);
}