Domain is a read-only member of SpatialReferenceBuilder. But I need to expand the coordinate system to fix out of bound during editing. But I can not do so through Domain since it is read-only. Is there a way to that?
Hi Fayu,
We will add a setter for the Domain property in the next release. In the meantime, you can change the xy-scale which will change the domain.
Here is an example:
<SPAN class="keyword token">const</SPAN> <SPAN class="keyword token">long</SPAN> suLimit <SPAN class="operator token">=</SPAN> <SPAN class="number token">9007199254740990</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="comment token">// Default domain for Web Mercator is xmin = -20037700, </SPAN> <SPAN class="comment token">// ymin = -30241100, xmax = 900699887774.099, ymax = 900689684374.099</SPAN> <SPAN class="comment token">// with xyScale = 10000</SPAN> <SPAN class="comment token">// To change the domain change the xyScale. This will keep the same false origin, </SPAN> <SPAN class="comment token">// but xmax and ymax will change.</SPAN> <SPAN class="comment token">// Make the xyScale smaller => xmax, ymax are bigger. </SPAN> <SPAN class="comment token">// xyScale bigger => xmax, ymax are smaller.</SPAN> SpatialReferenceBuilder builder <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">new</SPAN> <SPAN class="token class-name">SpatialReferenceBuilder</SPAN><SPAN class="punctuation token">(</SPAN>SpatialReferences<SPAN class="punctuation token">.</SPAN>WebMercator<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="comment token">// Suppose I know what I want my domain to be, then I have to figure out the scale. </SPAN> <SPAN class="comment token">// xyScale = suLimit / (xmax - xmin)</SPAN> <SPAN class="comment token">// assuming that xmax - xmin = ymax - ymin i.e. domain is a square.</SPAN> <SPAN class="comment token">// If xmax - xmin != ymax - ymin, take the larger of the two.</SPAN> <SPAN class="comment token">// Expand the default domain</SPAN> <SPAN class="keyword token">double</SPAN> xMin <SPAN class="operator token">=</SPAN> <SPAN class="operator token">-</SPAN><SPAN class="number token">20037700</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="keyword token">double</SPAN> xMax <SPAN class="operator token">=</SPAN> <SPAN class="number token">9007179217040.99</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="keyword token">double</SPAN> yMin <SPAN class="operator token">=</SPAN> <SPAN class="operator token">-</SPAN><SPAN class="number token">30241100</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="keyword token">double</SPAN> yMax <SPAN class="operator token">=</SPAN> <SPAN class="number token">9007169013640.99</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="keyword token">double</SPAN> xyScale <SPAN class="operator token">=</SPAN> suLimit <SPAN class="operator token">/</SPAN> Math<SPAN class="punctuation token">.</SPAN><SPAN class="token function">Max</SPAN><SPAN class="punctuation token">(</SPAN>xMax <SPAN class="operator token">-</SPAN> xMin<SPAN class="punctuation token">,</SPAN> yMax <SPAN class="operator token">-</SPAN> yMin<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="comment token">// xyScale = 1000</SPAN> builder<SPAN class="punctuation token">.</SPAN>XYScale <SPAN class="operator token">=</SPAN> xyScale<SPAN class="punctuation token">;</SPAN> Envelope domain <SPAN class="operator token">=</SPAN> builder<SPAN class="punctuation token">.</SPAN>Domain<SPAN class="punctuation token">;</SPAN> Console<SPAN class="punctuation token">.</SPAN>Out<SPAN class="punctuation token">.</SPAN><SPAN class="token function">WriteLine</SPAN><SPAN class="punctuation token">(</SPAN>$<SPAN class="string token">"xMin = {domain.XMin}"</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN> Console<SPAN class="punctuation token">.</SPAN>Out<SPAN class="punctuation token">.</SPAN><SPAN class="token function">WriteLine</SPAN><SPAN class="punctuation token">(</SPAN>$<SPAN class="string token">"xMax = {domain.XMax}"</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN> Console<SPAN class="punctuation token">.</SPAN>Out<SPAN class="punctuation token">.</SPAN><SPAN class="token function">WriteLine</SPAN><SPAN class="punctuation token">(</SPAN>$<SPAN class="string token">"yMin = {domain.YMin}"</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN> Console<SPAN class="punctuation token">.</SPAN>Out<SPAN class="punctuation token">.</SPAN><SPAN class="token function">WriteLine</SPAN><SPAN class="punctuation token">(</SPAN>$<SPAN class="string token">"yMax = {domain.YMax}"</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
Let me know if you have any questions.
Annette
Aangemelde leden kunnen berichten plaatsen, updates volgen en meer. Nieuw hier? Registreer een gratis account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.