本文整理汇总了C#中Envelope类的典型用法代码示例。如果您正苦于以下问题:C# Envelope类的具体用法?C# Envelope怎么用?C# Envelope使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Envelope类属于命名空间,在下文中一共展示了Envelope类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ComputeVertexEnvelope
private static Envelope ComputeVertexEnvelope(IEnumerable<Vertex> vertices)
{
Envelope env = new Envelope();
foreach (Vertex v in vertices)
env.ExpandToInclude(v.Coordinate);
return env;
}
示例2: Grid
public static IGeometry Grid(IGeometry g, int nCells)
{
var geoms = new List<IGeometry>();
var env = FunctionsUtil.GetEnvelopeOrDefault(g);
var geomFact = FunctionsUtil.GetFactoryOrDefault(g);
var nCellsOnSide = (int) Math.Sqrt(nCells) + 1;
var cellSizeX = env.Width/nCellsOnSide;
var cellSizeY = env.Height/nCellsOnSide;
for (var i = 0; i < nCellsOnSide; i++)
{
for (var j = 0; j < nCellsOnSide; j++)
{
var x1 = env.MinX + i * cellSizeX;
var y1 = env.MinY + j * cellSizeY;
var x2 = env.MinX + (i+1) * cellSizeX;
var y2 = env.MinY + (j+1) * cellSizeY;
var cellEnv = new Envelope(x1, x2, y1, y2);
geoms.Add(geomFact.ToGeometry(cellEnv));
}
}
return geomFact.BuildGeometry(geoms);
}
示例3: GetSource
protected override void GetSource( Envelope extent, int width, int height, DynamicLayer.OnImageComplete onComplete )
{
_currentWidth = width;
_currentHeight = height;
MapPoints = new List<MapPoint>();
//Make up some dummy data
int count = 0;
while( count < 1000 )
{
MapPoints.Add( new MapPoint( extent.XMin + ( extent.Width * ( _random.Next( 100 ) / 100.00 ) ),
extent.YMin + ( extent.Height * ( _random.Next( 100 ) / 100.00 ) ),
extent.SpatialReference ) );
count++;
}
//Make up some dummy data
_pngRenderer = new PixelPngRenderer( _currentWidth, _currentHeight, MapPoints );
ParameterizedThreadStart starter = new ParameterizedThreadStart( ( pngRenderer ) =>
{
Stream imageStream = InitalizeImage( pngRenderer as PixelPngRenderer );
Dispatcher.BeginInvoke( () =>
{
_image = new BitmapImage();
_image.SetSource( imageStream );
onComplete( _image, width, height, extent );
} );
} );
new Thread( starter ).Start( _pngRenderer );
}
示例4: Serialize
/// <summary>
/// Serialize an envelope
/// to a string
/// </summary>
/// <param name="envelope"></param>
/// <returns></returns>
public string Serialize(Envelope envelope)
{
if (envelope == null)
{
throw new ArgumentNullException("envelope");
}
if (envelope is Notification)
{
return JsonSerializer<Notification>.Serialize((Notification)envelope);
}
else if (envelope is Message)
{
return JsonSerializer<Message>.Serialize((Message)envelope);
}
else if (envelope is Command)
{
return JsonSerializer<Command>.Serialize((Command)envelope);
}
else if (envelope is Session)
{
return JsonSerializer<Session>.Serialize((Session)envelope);
}
else
{
throw new ArgumentException("The envelope type is unknown");
}
}
示例5: FindContinuation
// virtual for testing as usual
public virtual async Task<IContinuation> FindContinuation(Envelope envelope, IEnvelopeContext context)
{
foreach (var handler in _handlers)
{
var continuation = await handler.Handle(envelope).ConfigureAwait(false);
if (continuation != null)
{
context.DebugMessage(() => new EnvelopeContinuationChosen
{
ContinuationType = continuation.GetType(),
HandlerType = handler.GetType(),
Envelope = envelope.ToToken()
});
return continuation;
}
}
// TODO - add rules for what to do when we have no handler
context.DebugMessage(() => new EnvelopeContinuationChosen
{
ContinuationType = typeof(MoveToErrorQueue),
HandlerType = typeof(HandlerPipeline),
Envelope = envelope.ToToken()
});
return new MoveToErrorQueue(new NoHandlerException(envelope.Message.GetType()));
}
示例6: Initialize
private void Initialize()
{
// Create new Map with basemap
Map myMap = new Map(Basemap.CreateTopographic());
// Create and set initial map area
Envelope initialLocation = new Envelope(
-1.30758164047166E7, 4014771.46954516, -1.30730056797177E7, 4016869.78617381,
SpatialReferences.WebMercator);
myMap.InitialViewpoint = new Viewpoint(initialLocation);
// Create uri to the used feature service
var serviceUri = new Uri(
"http://sampleserver6.arcgisonline.com/arcgis/rest/services/PoolPermits/FeatureServer/0");
// Create feature table for the pools feature service
ServiceFeatureTable poolsFeatureTable = new ServiceFeatureTable(serviceUri);
// Define the request mode
poolsFeatureTable.FeatureRequestMode = FeatureRequestMode.OnInteractionNoCache;
// Create FeatureLayer that uses the created table
FeatureLayer poolsFeatureLayer = new FeatureLayer(poolsFeatureTable);
// Add created layer to the map
myMap.OperationalLayers.Add(poolsFeatureLayer);
// Assign the map to the MapView
MyMapView.Map = myMap;
}
示例7: Process
protected override void Process(object state)
{
Initialize();
Successful = false;
if (ReceivedEnvelope != null && ValidateProcessState())
{
ProcessRequest();
Envelope reply = new Envelope()
{
Message = CreateReply(),
Ep = ReceivedEnvelope.Ep
};
// the msgNr is the next one for this process
// the convId is the same as the requester's convId
reply.Message.SetMessageAndConversationNumbers(MessageNumber.Create(), ReceivedEnvelope.Message.ConvId);
CommSubsystem.Communicator.Send(reply);
Successful = true;
}
if (!Successful)
ProcessFailure();
Stop();
}
示例8: Should_Not_Continue_Processing_If_Processor_Does_Not_Call_Continuation
public void Should_Not_Continue_Processing_If_Processor_Does_Not_Call_Continuation()
{
// create an envelope and context
Envelope env = new Envelope() { Payload = Encoding.UTF8.GetBytes("Test") };
EnvelopeContext ctx = new EnvelopeContext(EnvelopeContext.Directions.In, env);
// mock a transport provider and envelope processor
Mock<ITransportProvider> txMock = _mocker.Create<ITransportProvider>();
Mock<IEnvelopeProcessor> procMock = _mocker.Create<IEnvelopeProcessor>();
// create a processor chain and add the mock processor to it
List<IEnvelopeProcessor> processorChain = new List<IEnvelopeProcessor>();
processorChain.Add(procMock.Object);
// the continuation that, if called, fails the test
Action continuation = new Action( () =>
Assert.Fail("The continuation action should not have been called"));
// this is what we're testing (extended class gives public access to protected method)
ExtendedDefaultEnvelopeBus bus = new ExtendedDefaultEnvelopeBus(txMock.Object);
bus.PublicProcessEnvelope(ctx, processorChain, continuation);
// make sure that the processor was called once
procMock.Verify(proc => proc.ProcessEnvelope(ctx, It.IsAny<Action>()), Times.Once());
// and that since it did nothing, the transport provider didn't get the envelope
txMock.Verify(tx => tx.Send(env), Times.Never());
}
示例9: FindGeoNearPoint
public static FeatureDataRow FindGeoNearPoint(GeoAPI.Geometries.IPoint point, VectorLayer layer, double amountGrow)
{
var box = new Envelope(point.Coordinate);
box.ExpandBy(amountGrow);
var fds = new FeatureDataSet();
layer.DataSource.ExecuteIntersectionQuery(box, fds);
FeatureDataRow result = null;
var minDistance = double.MaxValue;
foreach (FeatureDataTable fdt in fds.Tables)
{
foreach (FeatureDataRow fdr in fdt.Rows)
{
if (fdr.Geometry != null)
{
var distance = point.Distance(fdr.Geometry);
if (distance < minDistance)
{
result = fdr;
minDistance = distance;
}
}
}
}
return result;
}
示例10: Send
public async override Task Send(Envelope envelope, params string[] messages)
{
await base.Send(envelope, messages);
if (messages == null)
{
return;
}
foreach (var message in messages.Where(message => !string.IsNullOrWhiteSpace(message)))
{
var escapedMessage = WebUtility.HtmlEncode(message);
var args = JsonConvert.SerializeObject(new
{
username = Robot.Name,
channel =
string.IsNullOrEmpty(envelope.User.Room)
? envelope.User.Name
: _channelMapping.GetValueOrDefault(envelope.User.Room, envelope.User.Room),
text = escapedMessage,
link_names = _linkNames ? 1 : 0
});
await Post("/services/hooks/hubot", args);
}
}
示例11: EnvelopeSizeCheck
public void EnvelopeSizeCheck()
{
double w = 0;
// Measure starting point memory use
var start = GC.GetTotalMemory(true);
// Allocate a new array of 100000 Extent classes.
// If methods don't count, should be about 3,200,000 bytes.
var memhog = new Envelope[100000];
for (var i = 0; i < 100000; i++)
{
memhog[i] = new Envelope(new Coordinate(0, 0, 0), new Coordinate(1, 1, 1));
}
// Obtain measurements after creating the new byte[]
var end = GC.GetTotalMemory(true);
Debug.WriteLine("width: " + w);
var size = (end - start) / 100000;
// Ensure that the Array stays in memory and doesn't get optimized away
Debug.WriteLine("Memory size of Extent = " + size);
// Size of Envelope = 104
}
示例12: Initialize
public override void Initialize()
{
FullExtent = new Envelope(-cornerCoordinate, -cornerCoordinate, cornerCoordinate, cornerCoordinate)
{
SpatialReference = new SpatialReference(WKID)
};
//This layer's spatial reference
//Set up tile information. Each tile is 256x256px, 19 levels.
TileInfo = new TileInfo
{
Height = 256,
Width = 256,
Origin = new MapPoint(-cornerCoordinate, cornerCoordinate) { SpatialReference = new SpatialReference(WKID) },
Lods = new Lod[6]
};
//Set the resolutions for each level. Each level is half the resolution of the previous one.
var resolution = cornerCoordinate * 2 / 256;
for (var i = 0; i < TileInfo.Lods.Length; i++)
{
TileInfo.Lods[i] = new Lod { Resolution = resolution };
resolution /= 2;
}
//Call base initialize to raise the initialization event
base.Initialize();
base.Initialize();
}
示例13: ExecuteGeometryReader
public IGeometryReader ExecuteGeometryReader(SpatialPredicate predicate, Envelope envelope)
{
if (predicate != SpatialPredicate.Intersects)
throw new NotSupportedException();
return new ProviderGeometryReader(_provider.GetGeometriesInView(envelope));
}
示例14: WorldFileLoaded
private void WorldFileLoaded(object sender, DownloadStringCompletedEventArgs e)
{
//Checks to see if there was an error
if (e.Error == null)
{
//grab the data from the world file
string myData = e.Result;
//split string into an array based on new line characters
string[] lines = myData.Split(new string[] { "\r\n", "\n" }, StringSplitOptions.RemoveEmptyEntries);
//convert the strings into doubles
double[] coordValues = new double[6];
for(int i = 0; i < 6; i++) {
coordValues[i] = Convert.ToDouble(lines[i]);
}
//calculate the pixel height and width in real world coordinates
double pixelWidth = Math.Sqrt(Math.Pow(coordValues[0], 2) + Math.Pow(coordValues[1], 2));
double pixelHeight = Math.Sqrt(Math.Pow(coordValues[2], 2) + Math.Pow(coordValues[3], 2));
//Create a map point for the top left and bottom right
MapPoint topLeft = new MapPoint(coordValues[4], coordValues[5]);
MapPoint bottomRight = new MapPoint(coordValues[4] + (pixelWidth * imageWidth), coordValues[5] + (pixelHeight * imageHeight));
//create an envelope for the elmently layer
Envelope extent = new Envelope(topLeft.X, topLeft.Y, bottomRight.X, bottomRight.Y);
ElementLayer.SetEnvelope(image, extent);
//Zoom to the extent of the image
MyMap.Extent = extent;
}
}
示例15: Send
public void Send(object message, IDictionary<string, string> headers)
{
// create an envelope for the message
Envelope newEnvelope = new Envelope();
newEnvelope.Headers = headers ?? new Dictionary<string, string>();
// create a message context for message processing
MessageContext ctx = new MessageContext(
MessageContext.Directions.Out, newEnvelope, message);
// process the message
this.ProcessMessage(ctx, () =>
{
try
{
_envelopeSender.Send(ctx.Envelope);
}
catch (Exception ex)
{
string msg = "Failed to send an envelope.";
Log.Error(msg, ex);
throw new MessageException(msg, ex);
}
});
}