marci002 / proj4dart Goto Github PK
View Code? Open in Web Editor NEWProj4dart is a Dart library to transform point coordinates from one coordinate system to another, including datum transformations.
License: MIT License
Proj4dart is a Dart library to transform point coordinates from one coordinate system to another, including datum transformations.
License: MIT License
I'm trying to transform from EPSG:26716 to EPSG:4326, and the results I get with proj4dart are slightly off.
Here's the code:
final tuple = proj4.ProjectionTuple(
fromProj: proj4.Projection.parse('+proj=utm +zone=16 +datum=NAD27 +units=m +no_defs'),
toProj: proj4.Projection.WGS84,
);
final pointSrc = proj4.Point(x: 444650, y: 4640510);
final pointForward = tuple.forward(pointSrc);
print('Transform point ${pointSrc.toArray()} from EPSG:26716 to EPSG:4326: ${pointForward.toArray()}');
proj4dart gives [-87.66744437695456, 41.9143951210944]
while epsg.io gives [-87.6674992, 41.9165563]
cf https://epsg.io/transform#s_srs=26716&t_srs=4326&x=444650.0000000&y=4640510.0000000
The difference in latitude is particularly noticeable. Am I misusing the library?
Even if this is happening in a flutter_map project, I feel that it makes sense to post the issue here.
I am trying to load a WMS layer with a defined CRS. What I am doing is more or less:
final resolutions = <double>[
134217728, // 20
67108864,
33554432,
16777216,
8388608,
4194304, //15
2097152,
1048576,
524288,
262144,
131072, // 10
65536,
32768,
16384,
8192,
4096, // 5
2048,
1024,
512,
256,
128, // 0
];
var crs = Proj4Crs.fromFactory(
code: 'EPSG:3857',
proj4Projection: projection3857,
resolutions: resolutions);
List<LayerOptions> layers = [
TileLayerOptions(
opacity: 1,
backgroundColor: Colors.transparent,
wmsOptions: WMSTileLayerOptions(
crs: crs,
transparent: true,
format: imageFormat,
baseUrl: _getCapabilitiesUrl,
layers: [_layerName],
),
)
];
But on creation of the layer, I am getting:
The setter 'z=' was called on null.
Receiver: null
Tried calling: z=null
with the following stacktrace:
The relevant error-causing widget was
FlutterMap
lib/…/core/onlinesourcespage.dart:216
When the exception was thrown, this was the stack
#0 Object.noSuchMethod (dart:core-patch/object_patch.dart:53:5)
#1 Projection.transform package:proj4dart/…/classes/projection.dart:171
#2 _Proj4Projection.project package:flutter_map/…/crs/crs.dart:452
#3 WMSTileLayerOptions.getUrl package:flutter_map/…/layer/tile_layer.dart:262
#4 TileProvider.getTileUrl package:flutter_map/…/tile_provider/tile_provider.dart:20
...
Am I missing something in the creation?
Just as info, if it helps:
On a sidenote: when removing the crs option it works.
Hi, I am sure I am doing something wrong here, but I can't find what and how, so after hours of trial, I will ask you to see if there is an issue. :-)
I am converting a 3857 bbox to 4326.
var originPrj = proj4dart.Projection.parse(wktPrj);
var destPrj = proj4dart.Projection("EPSG:4326");
var ll = proj4dart.Point(x: west, y: south);
var llDest = originPrj.transform(destPrj, ll);
where wktPrj is read from a prj file. That one is read properly and recognises the projection correctly (PseudoMercatorProjection).
But the converted Y for some reason is off.
For example converting:
west: 1235116.6370151439
south: 5852571.412104731
should give me:
x: 11.0952417
y: 46.4488475
but the y I get is:
y: 46.6408787
Do you have any idea what that might happen?
Hello,
I have a problem with custom crs in flutter_map. Could you help me?
This is my code:
List<double> getResolutions(double maxX, double minX, int zoom, [double tileSize = 256.0]) {
var size = (maxX - minX) / tileSize;
return List.generate(zoom, (z) => size / math.pow(2, z));
}
int r = 6378137;
double _boundsD = r * math.pi;
final Bounds<double> _bounds = Bounds<double>(
CustomPoint<double>(532687.840000, 1250489.697300),
CustomPoint<double>(607009.080400, 1345845.903300),
);
final resolutions = getResolutions(607009.080400, 532687.840000, 19);
final maxZoom = (resolutions.length - 1).toDouble();
var def = '+proj=tmerc +lat_0=0 +lon_0=108.25 +k=0.9999 +x_0=500000 +y_0=0 +ellps=WGS84 +towgs84=-191.90441429,-39.30318279,-111.45032835,0.00928836,-0.01975479,0.00427372,0.252906278 +units=m +no_defs';
var epsg9217 = proj4.Projection.add('EPSG:9217', def);
var epsg9217CRS = Proj4Crs.fromFactory(
code: 'EPSG:9217',
proj4Projection: epsg9217,
resolutions: resolutions,
bounds: _bounds,
origins: [CustomPoint(-5122600.0, 1.00011E7)],
);
In main FlutterMap:
FlutterMap(
options: MapOptions(
crs: Epsg3857(),
),
children: [
TileLayerWidget(
options: TileLayerOptions(
backgroundColor: Colors.transparent,
wmsOptions: WMSTileLayerOptions(
crs: const Epsg3857()
version: '1.1.1',
transparent: true,
baseUrl: 'https://ows.terrestris.de/osm/service?',
layers: ["OSM-WMS"],
)
))
],
layers: [
TileLayerOptions(
backgroundColor: Colors.transparent,
fastReplace: true,
wmsOptions: WMSTileLayerOptions(
crs: epsg9217CRS,
version: '1.3.0',
transparent: true,
baseUrl: <wms_server_url>,
layers: ['2,3'],
),
))
]
)
Layer 'OSM-WMS' is show on my application but layer ('2,3') is not.
I console url that generate by WMSTileLayerOptions but BBOX is not correct.
Log : 499804.8535484949, 10000988.210334396, 499804.8535484949, 10000988.210334396
In javascript project, I use proj4js and BBOX is correct.
Log in javascript: 582600.854078125, 1278053.6005968752, 583345.8244375, 1278798.5709562502
This is code of javascript:
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/proj4-src.min.js"></script>
<script src="https://cdn.jsdelivr.net/gh/openlayers/openlayers.github.io@master/en/v6.6.1/build/ol.js"></script>
const newProjCode = 'EPSG:9217';
const def = "+proj=tmerc +lat_0=0 +lon_0=108.25 +k=0.9999 +x_0=500000 +y_0=0 +ellps=WGS84 +towgs84=-191.90441429,-39.30318279,-111.45032835,0.00928836,-0.01975479,0.00427372,0.252906278 +units=m +no_defs";
proj4.defs(newProjCode, def);
ol.proj.proj4.register(proj4);
const projection = new ol.proj.Projection({
code: 'EPSG:9217',
extent: [532687.8399999999, 1250489.6973, 607009.0804000003, 1345845.9033000004], // [540286.530000, 1276528.530000, 585024.462000, 1318764.630000],
units: 'm',
});
Thank you.
P/S: This is my WMS Capabilities:
This XML file does not appear to have any style information associated with it. The document tree is shown below.
<WMS_Capabilities xmlns="http://www.opengis.net/wms" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:esri_wms="http://www.esri.com/wms" version="1.3.0" xsi:schemaLocation="http://www.opengis.net/wms http://schemas.opengis.net/wms/1.3.0/capabilities_1_3_0.xsd http://www.esri.com/wms https://localhost:6080/arcgis/services/Test_BD/BDN/MapServer/WmsServer?version=1.3.0%26service=WMS%26request=GetSchemaExtension">
<Service>
<Name>
<![CDATA[ WMS ]]>
</Name>
<Title>
<![CDATA[ Test_BD_BDN ]]>
</Title>
<Abstract>WMS</Abstract>
<KeywordList>
<Keyword>
<![CDATA[ ]]>
</Keyword>
</KeywordList>
<OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple" xlink:href="https://localhost:6080/arcgis/services/Test_BD/BDN/MapServer/WmsServer?"/>
<ContactInformation>
<ContactPersonPrimary>
<ContactPerson>
<![CDATA[ ]]>
</ContactPerson>
<ContactOrganization>
<![CDATA[ ]]>
</ContactOrganization>
</ContactPersonPrimary>
<ContactPosition>
<![CDATA[ ]]>
</ContactPosition>
<ContactAddress>
<AddressType>
<![CDATA[ ]]>
</AddressType>
<Address>
<![CDATA[ ]]>
</Address>
<City>
<![CDATA[ ]]>
</City>
<StateOrProvince>
<![CDATA[ ]]>
</StateOrProvince>
<PostCode>
<![CDATA[ ]]>
</PostCode>
<Country>
<![CDATA[ ]]>
</Country>
</ContactAddress>
<ContactVoiceTelephone>
<![CDATA[ ]]>
</ContactVoiceTelephone>
<ContactFacsimileTelephone>
<![CDATA[ ]]>
</ContactFacsimileTelephone>
<ContactElectronicMailAddress>
<![CDATA[ ]]>
</ContactElectronicMailAddress>
</ContactInformation>
<Fees>
<![CDATA[ ]]>
</Fees>
<AccessConstraints>
<![CDATA[ ]]>
</AccessConstraints>
<MaxWidth>4096</MaxWidth>
<MaxHeight>4096</MaxHeight>
</Service>
<Capability>
<Request>
<GetCapabilities>
<Format>application/vnd.ogc.wms_xml</Format>
<Format>text/xml</Format>
<DCPType>
<HTTP>
<Get>
<OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple" xlink:href="https://localhost:6080/arcgis/services/Test_BD/BDN/MapServer/WmsServer?"/>
</Get>
</HTTP>
</DCPType>
</GetCapabilities>
<GetMap>
<Format>image/bmp</Format>
<Format>image/jpeg</Format>
<Format>image/tiff</Format>
<Format>image/png</Format>
<Format>image/png8</Format>
<Format>image/png24</Format>
<Format>image/png32</Format>
<Format>image/gif</Format>
<Format>image/svg+xml</Format>
<DCPType>
<HTTP>
<Get>
<OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple" xlink:href="https://localhost:6080/arcgis/services/Test_BD/BDN/MapServer/WmsServer?"/>
</Get>
</HTTP>
</DCPType>
</GetMap>
<GetFeatureInfo>
<Format>application/vnd.esri.wms_raw_xml</Format>
<Format>application/vnd.esri.wms_featureinfo_xml</Format>
<Format>application/vnd.ogc.wms_xml</Format>
<Format>application/geojson</Format>
<Format>text/xml</Format>
<Format>text/html</Format>
<Format>text/plain</Format>
<DCPType>
<HTTP>
<Get>
<OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple" xlink:href="https://localhost:6080/arcgis/services/Test_BD/BDN/MapServer/WmsServer?"/>
</Get>
</HTTP>
</DCPType>
</GetFeatureInfo>
<esri_wms:GetStyles>
<Format>application/vnd.ogc.sld+xml</Format>
<DCPType>
<HTTP>
<Get>
<OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple" xlink:href="https://localhost:6080/arcgis/services/Test_BD/BDN/MapServer/WmsServer?"/>
</Get>
</HTTP>
</DCPType>
</esri_wms:GetStyles>
</Request>
<Exception>
<Format>application/vnd.ogc.se_xml</Format>
<Format>application/vnd.ogc.se_inimage</Format>
<Format>application/vnd.ogc.se_blank</Format>
<Format>text/xml</Format>
<Format>XML</Format>
</Exception>
<Layer>
<Title>
<![CDATA[ Layers ]]>
</Title>
<CRS>CRS:84</CRS>
<CRS>EPSG:4326</CRS>
<CRS>EPSG:0</CRS>
<CRS>EPSG:9217</CRS>
<!-- 9217 is customized SR = PROJCS["VN2000",GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Transverse_Mercator"],PARAMETER["False_Easting",500000.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",108.25],PARAMETER["Scale_Factor",0.9999],PARAMETER["Latitude_Of_Origin",0.0],UNIT["Meter",1.0]] -->
<EX_GeographicBoundingBox>
<westBoundLongitude>108.549444</westBoundLongitude>
<eastBoundLongitude>109.233283</eastBoundLongitude>
<southBoundLatitude>11.307092</southBoundLatitude>
<northBoundLatitude>12.170651</northBoundLatitude>
</EX_GeographicBoundingBox>
<BoundingBox CRS="CRS:84" minx="108.549444" miny="11.307092" maxx="109.233283" maxy="12.170651"/>
<BoundingBox CRS="EPSG:4326" minx="11.307092" miny="108.549444" maxx="12.170651" maxy="109.233283"/>
<BoundingBox CRS="EPSG:0" minx="532687.840000" miny="1250489.697300" maxx="607009.080400" maxy="1345845.903300"/>
<BoundingBox CRS="EPSG:9217" minx="532687.840000" miny="1250489.697300" maxx="607009.080400" maxy="1345845.903300"/>
<Layer queryable="1">
<Title>
<![CDATA[ bdn ]]>
</Title>
<Abstract>
<![CDATA[ ]]>
</Abstract>
<CRS>CRS:84</CRS>
<CRS>EPSG:4326</CRS>
<CRS>EPSG:0</CRS>
<CRS>EPSG:9217</CRS>
<!-- 9217 is customized SR = PROJCS["VN2000",GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Transverse_Mercator"],PARAMETER["False_Easting",500000.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",108.25],PARAMETER["Scale_Factor",0.9999],PARAMETER["Latitude_Of_Origin",0.0],UNIT["Meter",1.0]] -->
<EX_GeographicBoundingBox>
<westBoundLongitude>108.549444</westBoundLongitude>
<eastBoundLongitude>109.233283</eastBoundLongitude>
<southBoundLatitude>11.307092</southBoundLatitude>
<northBoundLatitude>12.170651</northBoundLatitude>
</EX_GeographicBoundingBox>
<BoundingBox CRS="CRS:84" minx="108.549444" miny="11.307092" maxx="109.233283" maxy="12.170651"/>
<BoundingBox CRS="EPSG:4326" minx="11.307092" miny="108.549444" maxx="12.170651" maxy="109.233283"/>
<BoundingBox CRS="EPSG:0" minx="532687.840000" miny="1250489.697300" maxx="607009.080400" maxy="1345845.903300"/>
<BoundingBox CRS="EPSG:9217" minx="532687.840000" miny="1250489.697300" maxx="607009.080400" maxy="1345845.903300"/>
<Layer queryable="1">
<Name>1</Name>
<Title>
<![CDATA[ Hành chính cấp xã ]]>
</Title>
<Abstract>
<![CDATA[ ]]>
</Abstract>
<CRS>CRS:84</CRS>
<CRS>EPSG:4326</CRS>
<CRS>EPSG:0</CRS>
<CRS>EPSG:9217</CRS>
<!-- 9217 is customized SR = PROJCS["VN2000",GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Transverse_Mercator"],PARAMETER["False_Easting",500000.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",108.25],PARAMETER["Scale_Factor",0.9999],PARAMETER["Latitude_Of_Origin",0.0],UNIT["Meter",1.0]] -->
<EX_GeographicBoundingBox>
<westBoundLongitude>108.549444</westBoundLongitude>
<eastBoundLongitude>109.233267</eastBoundLongitude>
<southBoundLatitude>11.307092</southBoundLatitude>
<northBoundLatitude>12.166196</northBoundLatitude>
</EX_GeographicBoundingBox>
<BoundingBox CRS="CRS:84" minx="108.549444" miny="11.307092" maxx="109.233267" maxy="12.166196"/>
<BoundingBox CRS="EPSG:4326" minx="11.307092" miny="108.549444" maxx="12.166196" maxy="109.233267"/>
<BoundingBox CRS="EPSG:0" minx="532687.840000" miny="1250489.700000" maxx="607009.080000" maxy="1345353.090000"/>
<BoundingBox CRS="EPSG:9217" minx="532687.840000" miny="1250489.700000" maxx="607009.080000" maxy="1345353.090000"/>
<Style>
<Name>default</Name>
<Title>1</Title>
<LegendURL width="166" height="144">
<Format>image/png</Format>
<OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="https://localhost:6080/arcgis/services/Test_BD/BDN/MapServer/WmsServer?request=GetLegendGraphic%26version=1.3.0%26format=image/png%26layer=1" xlink:type="simple"/>
</LegendURL>
</Style>
</Layer>
<Layer queryable="1">
<Name>2</Name>
<Title>
<![CDATA[ Địa giới NT ]]>
</Title>
<Abstract>
<![CDATA[ ]]>
</Abstract>
<CRS>CRS:84</CRS>
<CRS>EPSG:4326</CRS>
<CRS>EPSG:0</CRS>
<CRS>EPSG:9217</CRS>
<!-- 9217 is customized SR = PROJCS["VN2000",GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Transverse_Mercator"],PARAMETER["False_Easting",500000.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",108.25],PARAMETER["Scale_Factor",0.9999],PARAMETER["Latitude_Of_Origin",0.0],UNIT["Meter",1.0]] -->
<EX_GeographicBoundingBox>
<westBoundLongitude>108.549444</westBoundLongitude>
<eastBoundLongitude>109.233283</eastBoundLongitude>
<southBoundLatitude>11.307092</southBoundLatitude>
<northBoundLatitude>12.170651</northBoundLatitude>
</EX_GeographicBoundingBox>
<BoundingBox CRS="CRS:84" minx="108.549444" miny="11.307092" maxx="109.233283" maxy="12.170651"/>
<BoundingBox CRS="EPSG:4326" minx="11.307092" miny="108.549444" maxx="12.170651" maxy="109.233283"/>
<BoundingBox CRS="EPSG:0" minx="532687.840900" miny="1250489.697300" maxx="607009.080400" maxy="1345845.903300"/>
<BoundingBox CRS="EPSG:9217" minx="532687.840900" miny="1250489.697300" maxx="607009.080400" maxy="1345845.903300"/>
<Style>
<Name>default</Name>
<Title>2</Title>
<LegendURL width="124" height="96">
<Format>image/png</Format>
<OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="https://localhost:6080/arcgis/services/Test_BD/BDN/MapServer/WmsServer?request=GetLegendGraphic%26version=1.3.0%26format=image/png%26layer=2" xlink:type="simple"/>
</LegendURL>
</Style>
</Layer>
<Layer queryable="1">
<Name>3</Name>
<Title>
<![CDATA[ Trụ sở UBND các cấp ]]>
</Title>
<Abstract>
<![CDATA[ ]]>
</Abstract>
<CRS>CRS:84</CRS>
<CRS>EPSG:4326</CRS>
<CRS>EPSG:0</CRS>
<CRS>EPSG:9217</CRS>
<!-- 9217 is customized SR = PROJCS["VN2000",GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Transverse_Mercator"],PARAMETER["False_Easting",500000.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",108.25],PARAMETER["Scale_Factor",0.9999],PARAMETER["Latitude_Of_Origin",0.0],UNIT["Meter",1.0]] -->
<EX_GeographicBoundingBox>
<westBoundLongitude>108.690979</westBoundLongitude>
<eastBoundLongitude>109.170210</eastBoundLongitude>
<southBoundLatitude>11.338382</southBoundLatitude>
<northBoundLatitude>12.006145</northBoundLatitude>
</EX_GeographicBoundingBox>
<BoundingBox CRS="CRS:84" minx="108.690979" miny="11.338382" maxx="109.170210" maxy="12.006145"/>
<BoundingBox CRS="EPSG:4326" minx="11.338382" miny="108.690979" maxx="12.006145" maxy="109.170210"/>
<BoundingBox CRS="EPSG:0" minx="548133.108100" miny="1253928.935000" maxx="600205.405400" maxy="1327670.126000"/>
<BoundingBox CRS="EPSG:9217" minx="548133.108100" miny="1253928.935000" maxx="600205.405400" maxy="1327670.126000"/>
<Style>
<Name>default</Name>
<Title>3</Title>
<LegendURL width="136" height="80">
<Format>image/png</Format>
<OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="https://localhost:6080/arcgis/services/Test_BD/BDN/MapServer/WmsServer?request=GetLegendGraphic%26version=1.3.0%26format=image/png%26layer=3" xlink:type="simple"/>
</LegendURL>
</Style>
<MinScaleDenominator>9449.404762</MinScaleDenominator>
<MaxScaleDenominator>236235.119048</MaxScaleDenominator>
</Layer>
</Layer>
</Layer>
</Capability>
</WMS_Capabilities>
According to https://proj.org/ , Could you plz declare which PROJ release version is used in this package.
I need PROJ 7.0.0 .
When running:
double lat = 0;
double lon = 0;
var pointSrc = Point(x: lon, y: lat);
var projSrc = Projection('EPSG:4326');
var projDst = Projection('Stere') ??
Projection.add('Stere', '+proj=stere +lat_0=90 +lon_0=0 +lat_ts=0 +ellps=WGS84 +x_0=0 y_0=0',
);
// Forward transform (lonlat -> Stereographic)
var pointForward = projSrc.transform(projDst, pointSrc);
I got the following error in line 107 of stere.dart (where x0 is first used):
Unhandled exception:
NoSuchMethodError: The method '+' was called on null.
Receiver: null
Tried calling: +(0.0)
Problem is solved in stere.dart by changing:
StereographicSouthProjection.init(ProjParams params)
: lat0 = params.lat0,
long0 = params.long0,
lat_ts = params.lat_ts ?? double.nan, // fix js behavior
x0 = params.x0,
y0 = params.y0,
to:
StereographicSouthProjection.init(ProjParams params)
: lat0 = params.lat0,
long0 = params.long0,
lat_ts = params.lat_ts ?? double.nan, // fix js behavior
x0 = params.x0 ?? 0,
y0 = params.y0 ?? 0,
Proj4js started to support nadgrids so it would be a nice feature to be implemented.
void transform() {
final latOffset = 0.04086; // degrees
final lonOffset = 0.36427; // degrees
final source = Projection.get('WGS84');
final target = Projection.parse(
'+proj=longlat +lon_0=$lonOffset +lat_0=$latOffset +ellps=WGS84 +units=m +no_defs');
final transform = ProjectionTuple(fromProj: source!, toProj: target);
final transformed = transform.forward(Point(x: 7.421, y: 79.546));
print('${transformed}');
}
I need to shift some coordinates to the correct location. I used the above code but it does not seems to transform the coordinates and only output the same coordinates that I give.
@maRci002 Hi, do you have any plan to migrate? Will you accept PR if I do?
Hi, I have the case in which I am reading the prj wkt from a file that is a sidecar file of a tiff file.
In the case the projection is not registered, I would like to advise the user that a certain epsg code needs to be added as definition.
Is there a way to get the epsg code from a projection object?
This would help a lot to keep a list of registered projections and handle them.
Now I am using Proj4Dart V2.0.0 & Flutter 3.0.4, found some big different of transform coordinates from my custom CRS. This is my code:
`import 'package:proj4dart/proj4dart.dart';
void main() {
var n1 = 1657193.5292;
var e1 = 834934.4417;
var ptSrc = Point(x: e1, y: n1);
var projSrc =
Projection.parse('+proj=utm +zone=47 +datum=WGS84 +units=m +no_defs');
var projDst = Projection.parse(
'+proj=tmerc +lat_0=0.0 +lon_0=102.25 +k_0=1.0 +x_0=500000 +y_0=0 +a=6378297.0 +b=6356911.77779 +towgs84=0.0,0.0,0.0,0,0,0,0 +units=m +no_defs type=crs');
var tuple = ProjectionTuple(fromProj: projSrc, toProj: projDst);
var ptDst = tuple.forward(ptSrc);
print(
'FORWARD: Transform point ${ptSrc.toArray()} from EPSG:32647 to custom projection: ${ptDst.toArray()}');
}
`
The console printed:
FORWARD: Transform point [834934.4417, 1657193.5292] from EPSG:32647 to custom projection: [485333.96880976285, 1655549.4642448912]
The correct answer must be [485333.9690, 1655549.7316].
This is very strange due to I used pyproj version of Python that derived from PROJ4 also but gave the correct coordinates.
This is my Python code with the same Proj4 strings:
`from pyproj import CRS, Transformer
projsrc = CRS.from_proj4('+proj=utm +zone=47 +datum=WGS84 +units=m +no_defs')
projdst = CRS.from_proj4('+proj=tmerc +lat_0=0.0 +lon_0=102.25 +k_0=1.0 +x_0=500000 +y_0=0 +a=6378297.0 +b=6356911.77779 +towgs84=0.0,0.0,0.0,0,0,0,0 +units=m +no_defs type=crs');
xx, yy = 834934.4417, 1657193.5292
transformer = Transformer.from_crs(projsrc, projdst)
ptdst = transformer.transform(xx=xx, yy=yy)
print(f'Source point x,y: {xx} {yy}')
print(f'Dest point x,y: {ptdst[0]} {ptdst[1]}')`
The console of Python printed:
Source point x,y: 834934.4417 1657193.5292
Dest point x,y: 485333.9689740725 1655549.7315796772
I am new to Dart/Flutter what I am doing wrong or is it Proj4Dart's bug? Please help me. I run this code on Windows 11.
Hello, I am trying to change the general latitude and longitude wgs84 coordinate system value to the TM128 coordinate system value.
I got the desired value by converting the wgs84 coordinate system to the Tm128 coordinate system in the proj4 package provided by node js.
const proj4 = require('proj4');
var from = 'WGS84'
var to = 'TM128'
proj4.defs('WGS84', "+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs");
proj4.defs('TM128', '+proj=tmerc +lat_0=38 +lon_0=128 +k=0.9999 +x_0=400000 +y_0=600000 +ellps=bessel +units=m +no_defs +towgs84=-115.80,474.99,674.11,1.16,-2.31,-1.63,6.43');
var xy = [126.947937,37.375219];
var result = proj4(from, to, xy);
console.log(result)
But I need a conversion function in flutter. Can you guide me?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.