java画两条线_java – 如何使用Geotools在shapefile上绘制一条线

这篇博客介绍了如何在Java中使用GeoTools库在Shapefile上绘制线。作者首先展示了GeoTools的QuickStart.java示例代码,并提到遇到困难在于如何根据用户点击的两点绘制线。接着,博客提供了一段代码示例,展示如何创建GeometryFactory,定义坐标并创建LineString。最后,博客建议将LineString转换为SimpleFeature,并将其添加到地图的图层中进行显示。
摘要由CSDN通过智能技术生成

我有一个打开的shapefile,看起来像这样:

现在我试图从我点击该地图的两个点画一条线;但是他们为QuickStart.java示例提供的代码异常模糊.

这是他们的代码:

package org.geotools.tutorial;

import java.io.File;

import org.geotools.data.FileDataStore;

import org.geotools.data.FileDataStoreFinder;

import org.geotools.data.simple.SimpleFeatureSource;

import org.geotools.map.FeatureLayer;

import org.geotools.map.Layer;

import org.geotools.map.MapContent;

import org.geotools.styling.SLD;

import org.geotools.styling.Style;

import org.geotools.swing.JMapFrame;

import org.geotools.swing.data.JFileDataStoreChooser;

import org.geotools.geometry.jts.JTSFactoryFinder;

import com.vividsolutions.jts.geom.Coordinate;

import com.vividsolutions.jts.geom.LineString;

/**

* Prompts the user for a shapefile and displays the contents on the screen in a map fram

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值