Trajectory similarity measures act as query predicates in trajectory databases, making them the key player in determining the query results. They also have a heavy impact on the query efficiency. An ideal measure should have the capability to accurately evaluate the similarity between any two trajectories in a very short amount of time. However, existing heuristic measures are mainly based on pointwise comparisons following hand-crafted rules, thus resulting in either poor quality results or low efficiency in many cases. Although several deep learning-based measures have recently aimed at these problems, their improvements are limited by the difficulties to learn the fine-grained spatial patterns of trajectories. To address these issues, we propose a contrastive learning-based trajectory modelling method named TrajCL, which is robust in application scenarios where the data set contains low-quality trajectories. Specifically, we present four trajectory augmentation methods and a novel dual-feature self-attention-based trajectory backbone encoder. The resultant model can jointly learn both the spatial and the structural patterns of trajectories. Our model does not involve any recurrent structures and thus has a high efficiency. Besides, our pre-trained backbone encoder can be fine-tuned towards other computationally expensive measures with minimal supervision data. Experimental results show that TrajCL is consistently and significantly more accurate and faster than the state-of-the-art trajectory similarity measures. After fine-tuning, i.e., when being used as an estimator for heuristic measures, TrajCL can even outperform the state-of-the-art supervised method by up to 32% in the accuracy for processing trajectory similarity queries.